env bug ?

Peter L. Peres plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Tue Mar 8 19:48:09 UTC 2005


On Tue, 8 Mar 2005, Lennart Sorensen wrote:

> On Tue, Mar 08, 2005 at 01:13:14AM +0200, Peter L. Peres wrote:
>> I seem to have a problem with env: a file that starts with:
>>
>> 	#!/usr/bin/env echo foo
>>
>> and is set +x and executes, will print:
>>
>> 	/usr/bin/env: echo foo: No such file or directory
>
> Do you have /bin/echo or do you only have the shell built in echo (bash
> has echo built in so it doesn't use /bin/echo normally, while env does
> use the real program from the PATH).
>
> Quite likely you do not have an echo _command_ at all then.

I do have it ;-) I gave echo as an exaple, that was not what I 
originally put there.

> /usr/bin/env echo foo, does work here.

here being ? My env is from debian potato or at most unstable.

My C program shows that Henry Spencer is right, and that the kernel 
passes all the arguments to env as a single word.

With a script called s which has a header:

#!/some/where/env2 -i a b c d e f

env2 prints the arguments:

1:'/some/where/env2' 2:'-i a b c d e f' 3:'./s'

Would a env replacement that splits its second argument on spaces and 
then execve's the first of those words with the rest as arguments, be 
useful ?

Peter
--
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