GNU bug report logs - #21672
env is not splitting command and argument as suggested by the synopsis

Previous Next

Package: coreutils;

Reported by: Esli <esli.kulisek <at> gmail.com>

Date: Mon, 12 Oct 2015 15:29:01 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21672 in the body.
You can then email your comments to 21672 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#21672; Package coreutils. (Mon, 12 Oct 2015 15:29:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Esli <esli.kulisek <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 12 Oct 2015 15:29:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Esli <esli.kulisek <at> gmail.com>
To: <bug-coreutils <at> gnu.org>
Subject: env is not splitting command and argument as suggested by the synopsis
Date: Mon, 12 Oct 2015 10:48:55 +0200
[Message part 1 (text/plain, inline)]
Hello,

 

  env is not splitting command and argument as suggested by the synopsis:

SYNOPSIS

       env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]

 

Example:

#!/usr/bin/env perl -w

produces:

/usr/bin/env: perl -w: No such file or directory

 

Apparently, env is looking for command "perl -w", not for command "perl" and
than passing him "-w"

 

Regards

   Petr

[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#21672; Package coreutils. (Mon, 12 Oct 2015 15:37:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Davide Brini <dave_br <at> gmx.com>
To: bug-coreutils <at> gnu.org
Subject: Re: bug#21672: env is not splitting command and argument as
 suggested by the synopsis
Date: Mon, 12 Oct 2015 17:35:56 +0200
On Mon, 12 Oct 2015 10:48:55 +0200, Esli <esli.kulisek <at> gmail.com> wrote:

> Hello,
> 
>  
> 
>   env is not splitting command and argument as suggested by the synopsis:
> 
> SYNOPSIS
> 
>        env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
> 
>  
> 
> Example:
> 
> #!/usr/bin/env perl -w
> 
> produces:
> 
> /usr/bin/env: perl -w: No such file or directory
> 
>  
> 
> Apparently, env is looking for command "perl -w", not for command "perl"
> and than passing him "-w"

This is due to how the shebang works under Linux, nothing to do with env,
see this page for all the details:

http://www.in-ulm.de/~mascheck/various/shebang/



-- 
D.




Added tag(s) notabug. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Mon, 12 Oct 2015 15:41:02 GMT) Full text and rfc822 format available.

Reply sent to Eric Blake <eblake <at> redhat.com>:
You have taken responsibility. (Mon, 12 Oct 2015 15:41:03 GMT) Full text and rfc822 format available.

Notification sent to Esli <esli.kulisek <at> gmail.com>:
bug acknowledged by developer. (Mon, 12 Oct 2015 15:41:03 GMT) Full text and rfc822 format available.

Message #15 received at 21672-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Esli <esli.kulisek <at> gmail.com>, 21672-done <at> debbugs.gnu.org
Subject: Re: bug#21672: env is not splitting command and argument as suggested
 by the synopsis
Date: Mon, 12 Oct 2015 09:40:37 -0600
[Message part 1 (text/plain, inline)]
tag 21672 notabug
thanks

On 10/12/2015 02:48 AM, Esli wrote:
> Hello,
> 
>  
> 
>   env is not splitting command and argument as suggested by the synopsis:

Thanks for the report.  However, this is a misunderstanding on your part
on how the kernel implements #! on your system, and has nothing to do
with env.  The same would happen for any other attempt you make on your
system to write a shebang line with more than one set of space separations.

In short, shebangs differ tremendously across systems in how they
behave, and so the common subset that you can portably rely on is
severely limited in what it can do.

> #!/usr/bin/env perl -w
> 
> produces:
> 
> /usr/bin/env: perl -w: No such file or directory

That's because on your system, #! magic supports exactly ONE argument,
whitespace included, and does NOT break it into words in the same way
the shell does.  So your kernel is invoking '/usr/bin/env' 'perl -w',
and env is blindly trying to execute 'perl -w' (which does not exist),
exactly as requested.  But it is not env's job to do word splitting.

You cannot mix /usr/bin/env PROG and options to PROG in the same #!
shebang.  It is not portable.  But it is a limitation of your system,
and not something env can work around.

If you were to use '#!/path/to/perl -w', then your kernel would attempt
to invoke '/path/to/perl' '-w'.  The trick for this is then determining
at installation time what to place in the file for /path/to/perl, since
there is no canonical location for perl across all systems.

Also, the perl documentation includes some hints on how to use
/usr/bin/env perl as the shebang line, and then, separate from that
line, enable options that you can't portably include in the shebang.
But as this is not the perl mailing list, and I'm not the expert in it,
I'm not going to go trying to find that documentation right now.

Therefore, I'm closing this as not a coreutils bug, although you should
feel free to add further comments on the topic as desired.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 10 Nov 2015 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 220 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.