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

From: Kevin Layer (layer@franz.com)
Date: Wed Feb 16 2000 - 18:34:30 EST


>> On Wed, Feb 16, 2000 at 10:49:35AM -0800, Kevin Layer wrote:
>> >
>> > 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
>> > 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.
>> >
>> > 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've hit the same problem once. I've "fixed" it by using the path compiled
>> in. An other option was an env variable. Don't like either of those two.

Neither of these are good enough for me, either. Passing to argv[0]
the whole thing is the right thing. The receiver can always strip off
the directory. As it is, though, you can add it back.

>> btw: Someone will probably tell that argv[0] is not always the executable
>> but could be a sym-link, which I my case was good enough, because it was
>> supposed to be in the same dir as the executable.

Right. I handle that possibility.

>> I think this behavior is new since 2.2, but not sure tho.
>>
>> Q

-
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