[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] [Approve?] Add 'Extensions' directories to compiler




On Dec 21, 2004, at 2:33 PM, James McCartney wrote:
no. a unix program's cwd is the directory that is the cwd where the
command is executed, not the directory where the program is stored.

I understand this. My question was wouldn't this mean that the scsynth
binary would have to be stored in ~/Library/Application
Support/SuperCollider?

no, you apparently don't understand. there is a difference between where a program is executed and where it is stored. you can execute any program in any directory by 'cd'ing to that directory before you execute the command.. where you store the program is irrelevant as long as it is in your shell's search path or you specify it explicitly.

Here's what you wrote;

>       var <>dir = "~/Library/Application Support/SuperCollider";
>
>       bootServerApp {
>               if (inProcess, {
>                       "booting internal".inform;
>                       this.bootInProcess;
>               },{
>                       unixCmd("cd " ++ dir ++ "; " ++ program ++
> options.asOptionsString(addr.port));
>                       ("booting " ++ addr.port.asString).inform;
>               });
>

Which cd's to ~/Library/Application Support/SuperCollider, and then executes the command that is defined in the classvar program.

Line 163 of Server.sc looks like;
program = "./scsynth";

So now that I've cd'd to ~/Library/Application Support/SuperCollider I'll execute the copy of scsynth in the current working directory since "./" explicitly refers to the current directory you are in. Since executing a binary in your PATH when you are explicit about the binary to use would be a security problem, the shell will only search for scsynth in ./. This means if scsynth isn't in ~/Library/Application Support/SuperCollider you get this (even when scsynth is in your PATH);

renderbandit:~/Library/Application Support/SuperCollider dave$ ls -l ~/Documents/SuperCollider3/build/scsynth -rwxr-xr-x 1 dave dave 2146720 21 Dec 04:31 /Users/dave/Documents/SuperCollider3/build/scsynth renderbandit:~/Library/Application Support/SuperCollider dave$ env PATH=$PATH:~/Documents/SuperCollider3/build ./scsynth
env: ./scsynth: No such file or directory

In other words, where you store the program is irrelevant as long as it's in your PATH and you _don't_ specify the the path to the binary explicitly.

In any case;

>                       unixCmd("cd " ++ dir ++ "; " ++ program ++
> options.asOptionsString(addr.port));

Is probably better as;
unixCmd("cd" ++ dir ++ " && " ++ program ++ options.asOptionsString(addr.port));