GNU bug report logs -
#31215
coreutils env fails in a bash shebang
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31215 in the body.
You can then email your comments to 31215 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org:
bug#31215; Package
coreutils.
(Thu, 19 Apr 2018 00:54:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
William Schmidt <t.william.schmidt <at> gmail.com>:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org.
(Thu, 19 Apr 2018 00:54:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I think I've found a bug in *coreutils*, *env*.
Linux debian 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23)
x86_64 GNU/Linux
All my Perl scripts contain either of these shebangs:
#!/usr/bin/env perl -w
or
#!/usr/bin/env perl -wd
When I attempt to run a Perl script with either of these shebangs in debian
I get:
/usr/bin/env: ‘perl -w’: No such file or directory
It is not perl that can't be found; it is either *env*'s or *bash*'s
handling of the argument. If I remove the *-w* and/or the *-wd* arguments
the scripts execute, but of course, without the benefit of those switches.
The man page for *env* asserts that any command may take an argument. I
have tried every way I can think of to quote the *-w* and the *-wd* but
*env* is treating these perl command line arguments as filenames, and since
they aren't files, renders that error message. I'm running the latest
*coreutils* as in this apt-get fragment:
Reading package lists... Done
Building dependency tree
Reading state information... Done
coreutils is already the newest version (8.26-3).
Both of these shebangs work correctly in macOS 10.13.3 with the native perl
from Apple and perlbrew perl. That is where I do most of my perl work but
now I need to move those scripts to debian, without changing the shebangs.
Is this a bug in *env*, something in bash or pilot error?
Regards,
T.W. Schmidt
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-coreutils <at> gnu.org:
bug#31215; Package
coreutils.
(Thu, 19 Apr 2018 03:04:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 31215 <at> debbugs.gnu.org (full text, mbox):
On 18/04/18 17:18, William Schmidt wrote:
> I think I've found a bug in *coreutils*, *env*.
>
> Linux debian 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23)
> x86_64 GNU/Linux
>
> All my Perl scripts contain either of these shebangs:
>
> #!/usr/bin/env perl -w
> or
> #!/usr/bin/env perl -wd
>
> When I attempt to run a Perl script with either of these shebangs in debian
> I get:
>
> /usr/bin/env: ‘perl -w’: No such file or directory
>
> It is not perl that can't be found; it is either *env*'s or *bash*'s
> handling of the argument. If I remove the *-w* and/or the *-wd* arguments
> the scripts execute, but of course, without the benefit of those switches.
>
> The man page for *env* asserts that any command may take an argument. I
> have tried every way I can think of to quote the *-w* and the *-wd* but
> *env* is treating these perl command line arguments as filenames, and since
> they aren't files, renders that error message. I'm running the latest
> *coreutils* as in this apt-get fragment:
>
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> coreutils is already the newest version (8.26-3).
>
> Both of these shebangs work correctly in macOS 10.13.3 with the native perl
> from Apple and perlbrew perl. That is where I do most of my perl work but
> now I need to move those scripts to debian, without changing the shebangs.
> Is this a bug in *env*, something in bash or pilot error?
The kernel passes "perl -w" to env as a single argument.
This was previous discussed at:
https://lists.gnu.org/archive/html/coreutils/2017-05/msg00020.html
We may add the -S option to support this usage.
cheers,
Pádraig
Added tag(s) notabug.
Request was from
Eric Blake <eblake <at> redhat.com>
to
control <at> debbugs.gnu.org.
(Thu, 19 Apr 2018 03:12:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Eric Blake <eblake <at> redhat.com>:
You have taken responsibility.
(Thu, 19 Apr 2018 03:12:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
William Schmidt <t.william.schmidt <at> gmail.com>:
bug acknowledged by developer.
(Thu, 19 Apr 2018 03:12:03 GMT)
Full text and
rfc822 format available.
Message #15 received at 31215-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tag 31215 notabug
thanks
On 04/18/2018 07:18 PM, William Schmidt wrote:
> I think I've found a bug in *coreutils*, *env*.
>
> Linux debian 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23)
> x86_64 GNU/Linux
>
> All my Perl scripts contain either of these shebangs:
>
> #!/usr/bin/env perl -w
> or
> #!/usr/bin/env perl -wd
That is inherently non-portable. On some operating systems (such as
GNU/Linux), the #! line is limited to EXACTLY ONE argument beyond the
name of the executable. But you are trying to shoehorn two arguments
("perl" and "-w"). Just because it may have worked on some other
operating systems does not make it portable.
There may be ways to do what you want by telling perl to turn on -w or
-wd in subsequent lines of the script, or you can rewrite the #! line to
use /path/to/perl instead of trying to make env do the work. Or perldoc
even includes some arcane formulas for using #!/bin/sh as the start, and
then exec into perl with as many desired arguments as you want
(including by using env to locate perl), as the first line when
interpreted by sh, while that exec line is skipped by perl.
But as this is a limitation of your operating system's handling of #!
and not a bug in env, there's nothing we can do about it in coreutils'
env. So I'm closing this bug.
> Both of these shebangs work correctly in macOS 10.13.3 with the native perl
> from Apple and perlbrew perl. That is where I do most of my perl work but
> now I need to move those scripts to debian, without changing the shebangs.
> Is this a bug in *env*, something in bash or pilot error?
Pilot error, as you have used two different OS with different #!
handling rules.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | 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.
(Thu, 17 May 2018 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 96 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.