[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Alpine: useless-if-before-free: Exec format error
From: |
Bruno Haible |
Subject: |
Re: Alpine: useless-if-before-free: Exec format error |
Date: |
Sat, 15 Jun 2019 04:03:40 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-145-generic; KDE/5.18.0; x86_64; ; ) |
Paul Eggert wrote:
> Perhaps we
> should just prepend "#!/bin/sh" or "#!/usr/bin/env perl" (not sure
> which) and let people on weird systems fix things by hand.
"#!/usr/bin/env perl" does not work on GuixSD (where the only program
that has a hardcoded file name is /bin/sh; there is no /usr and no
/bin/env on this distro).
Naively prepending "#!/bin/sh" leads to this (with perl 5.22.1):
$ build-aux/useless-if-before-free
/bin/sh: 0: Illegal option -w
$ strace -f build-aux/useless-if-before-free 2>&1 | grep ^exec
execve("build-aux/useless-if-before-free",
["build-aux/useless-if-before-free"], [/* 79 vars */]) = 0
execve("/home/bruno/bin/perl", ["perl", "-wST",
"build-aux/useless-if-before-free"], [/* 79 vars */]) = -1 ENOENT (No such file
or directory)
execve("/home/bruno/local/bin/perl", ["perl", "-wST",
"build-aux/useless-if-before-free"], [/* 79 vars */]) = -1 ENOENT (No such file
or directory)
execve("/darch/x86_64-linux-gnu/gnu/bin/perl", ["perl", "-wST",
"build-aux/useless-if-before-free"], [/* 79 vars */]) = -1 ENOENT (No such file
or directory)
execve("/arch/local/x86_64-linux-gnu/bin/perl", ["perl", "-wST",
"build-aux/useless-if-before-free"], [/* 79 vars */]) = -1 ENOENT (No such file
or directory)
execve("/arch/local/x86_64-linux/bin/perl", ["perl", "-wST",
"build-aux/useless-if-before-free"], [/* 79 vars */]) = -1 ENOENT (No such file
or directory)
execve("/usr/local/sbin/perl", ["perl", "-wST",
"build-aux/useless-if-before-free"], [/* 79 vars */]) = -1 ENOENT (No such file
or directory)
execve("/usr/local/bin/perl", ["perl", "-wST",
"build-aux/useless-if-before-free"], [/* 79 vars */]) = -1 ENOENT (No such file
or directory)
execve("/usr/sbin/perl", ["perl", "-wST", "build-aux/useless-if-before-free"],
[/* 79 vars */]) = -1 ENOENT (No such file or directory)
execve("/usr/bin/perl", ["perl", "-wST", "build-aux/useless-if-before-free"],
[/* 79 vars */]) = 0
execve("/bin/sh", ["/bin/sh", "-wST", "build-aux/useless-if-before-free"], [/*
79 vars */]) = 0
So, what you can see is that the redirect from /bin/sh to perl works right.
But perl then sees the first line and redirects back to /bin/sh. In other
words, there is logic in perl that amounts to "I refuse to be executed
through scripts that start with '#!/bin/sh'".
This finding is confirmed by the following comment in the perl source code:
/* ALTERNATE_SHEBANG:
* This symbol, if defined, contains a "magic" string which may be used
* as the first line of a Perl program designed to be executed directly
* by name, instead of the standard Unix #!. If ALTERNATE_SHEBANG
* begins with a character other then #, then Perl will only treat
* it as a command line if it finds the string "perl" in the first
* word; otherwise it's treated as the first line of code in the script.
* (IOW, Perl won't hand off to another interpreter via an alternate
* shebang sequence that might be legal Perl code.)
*/
I propose this solution:
- Rename 'useless-if-before-free' to 'useless-if-before-free.pl',
removing the first 3 lines, and removing the execute permission.
Also update the reference to ME in the --help output.
- Add a shell script useless-if-before-free that merely does this:
#!/bin/sh
exec perl "$0".pl "$@"
- Update the module description, to list both
build-aux/useless-if-before-free and build-aux/useless-if-before-free.pl.
And likewise for the other programs:
build-aux/gitlog-to-changelog
build-aux/update-copyright
build-aux/announce-gen
build-aux/prefix-gnulib-mk
tests/test-update-copyright.sh
Bruno
- Alpine: useless-if-before-free: Exec format error, Tim Rühsen, 2019/06/14
- Re: Alpine: useless-if-before-free: Exec format error, Paul Eggert, 2019/06/14
- Re: Alpine: useless-if-before-free: Exec format error, Tim Rühsen, 2019/06/14
- Re: Alpine: useless-if-before-free: Exec format error, Bruno Haible, 2019/06/14
- Re: Alpine: useless-if-before-free: Exec format error, Eric Blake, 2019/06/14
- Re: Alpine: useless-if-before-free: Exec format error, Bruno Haible, 2019/06/14
- Re: Alpine: useless-if-before-free: Exec format error, Bruno Haible, 2019/06/14
- Re: Alpine: useless-if-before-free: Exec format error, Paul Eggert, 2019/06/14
- Re: Alpine: useless-if-before-free: Exec format error,
Bruno Haible <=
- Re: Alpine: useless-if-before-free: Exec format error, Paul Eggert, 2019/06/15
- Re: Alpine: useless-if-before-free: Exec format error, Bruno Haible, 2019/06/15
- Re: Alpine: useless-if-before-free: Exec format error, Darshit Shah, 2019/06/15
- Re: Emacs time stamp hook, Bruno Haible, 2019/06/15
- Re: Emacs time stamp hook, Darshit Shah, 2019/06/15
- Re: Emacs time stamp hook, Bruno Haible, 2019/06/15
- Re: Emacs time stamp hook, Paul Eggert, 2019/06/15
- Re: Emacs time stamp hook, Bruno Haible, 2019/06/15
- Re: Emacs time stamp hook, Jim Meyering, 2019/06/15
- Re: Emacs time stamp hook, Bruno Haible, 2019/06/16