env bug ?
Henry Spencer
henry-lqW1N6Cllo0sV2N9l4h3zg at public.gmane.org
Tue Mar 8 00:50:16 UTC 2005
On Mon, 7 Mar 2005, John Sellens wrote:
> | #!/usr/bin/env echo foo
> | /usr/bin/env: echo foo: No such file or directory
>
> Hmmm - there seems to be something different in the way Linux does #!
> lines than one might expect...
A very careful reading of the execve(2) manpage (on a somewhat old Red
Hat) indicates that the contents of the #! line are #!, the full pathname
of an interpreter, and optionally an argument. Note, "argument", singular
not plural. So all the remaining text on the line is being taken as *one*
argument.
This is actually quite a common restriction; supplying more than one
argument on the #! line has never been very portable.
> env is behaving correctly, based on the arguments it is given.
I concur.
> Some (including me) might claim that the kernel is invoking env
> incorrectly.
I wouldn't go that far... quite. I would say that the kernel is handling
an out-of-spec situation rather ungracefully. It isn't actually wrong but
really ought to do better.
Henry Spencer
henry-lqW1N6Cllo0sV2N9l4h3zg at public.gmane.org
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list