Re: #! and argv[0]: the path is removed before invoking the interpreter

From: Ahmon Dancy (dancy@franz.com)
Date: Wed Feb 16 2000 - 15:53:24 EST


>> Kevin Layer writes the following:
>> >I have an interpreter of #! scripts that absolutely needs to know the
>> >full path of where the executable is, and I can't assume it will be in
>>
>> Wrong.
>>
>> What full path?

The one specified after the '#!'

>> There can be many. Or none. It could be deleted right after
>> it starts up.
>>
>> There is no such thing as "the path to the current executable" in Unix.
>>
>> (In Linux 2.2 and up, readlink(/proc/self/exe) is close)
>>
>> >the user's path. Getting it in argv[0] is the cleanest way. That is,
>> >I can tell users they have to use the full path in the #!, if they
>> >want to use my interpreter.
>>
>> You should eliminate whatever design flaw you have that causes you to want
>> this information.
>>
>> >I believe the behavior of #! on Solaris goes all the way back to BSD
>> >in of the early 80's. FreeBSD 3.0 behaves as Solaris does.
>> >
>> >I hope this considered a bug. If there willingness to take a patch for
>> >it, I might work on making the fix.
>>
>> I hope the old BSD/Sysv behavior is considered a bug. It unnecessarily
>> exposes the difference between an executable in ELF or aout format and an
>> executable in #! format. argv[0] passed to main() should be the same that was
>> passed to execve().
>>
>>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:16 EST