On Wed, Apr 14, 2004 at 11:25:22PM -0700, Jeff Clites wrote:

> For Unix platforms at least, you should be able to do this:
> 
>       executablePath = isAbsolute($0) ? dirname($0) : cwd().dirname($0)
> 
>       (to mix a bunch of syntaxes)
> 
> during initialization before you've had a chance to chdir, and store 
> that away on the interpreter struct. That should work unless you've 
> gone out of your way to execute parrot with argv[0] set to something 
> "fake". I don't know what you'd do on Windows, but there must be 
> something.

I think that it can be fun on HP-UX (where for #! the kernel sets argv[0]
to the path of the script not the interpreter, despite the fact that the
script's path is going to be somewhere else in argv) and AIX (where it seems
that the kernel sets argv[0] to only the leafname of the interpreter,
rather than the full path).

But all this is from memory, and in turn for #! invocation one can always
parse the #! line to work out where the interpreter was (mmm. race
condition)

Nicholas Clark

Reply via email to