Reported by Tim Rühsen <tim.ruehsen@gmx.de>.
Idea by Paul Eggert.
* build-aux/useless-if-before-free: Use a prologue that starts with
'#!/bin/sh'.
* build-aux/announce-gen: Likewise.
* build-aux/gitlog-to-changelog: Likewise.
* build-aux/prefix-gnulib-mk: Likewise.
* build-aux/update-copyright: Likewise.
* tests/test-update-copyright.sh: Update test program accordingly.
+2019-06-15 Bruno Haible <bruno@clisp.org>
+
+ Fix scripts to have valid executable format on Alpine Linux.
+ Reported by Tim Rühsen <tim.ruehsen@gmx.de>.
+ Idea by Paul Eggert.
+ * build-aux/useless-if-before-free: Use a prologue that starts with
+ '#!/bin/sh'.
+ * build-aux/announce-gen: Likewise.
+ * build-aux/gitlog-to-changelog: Likewise.
+ * build-aux/prefix-gnulib-mk: Likewise.
+ * build-aux/update-copyright: Likewise.
+ * tests/test-update-copyright.sh: Update test program accordingly.
+
2019-06-10 Bruno Haible <bruno@clisp.org>
nproc: Ensure nproc(NPROC_ALL) ≥ nproc(NPROC_CURRENT) with glibc ≥ 2.26.
-eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
- & eval 'exec perl -wS "$0" $argv:q'
- if 0;
+#!/bin/sh
+#! -*-perl-*-
+# This is a prologue that allows to run a perl script as an executable
+# on systems that are compliant to a POSIX version before POSIX:2017.
+# On such systems, the usual invocation of an executable through execlp()
+# or execvp() fails with ENOEXEC if it is a script that does not start
+# with a #! line. The script interpreter mentioned in the #! line has
+# to be /bin/sh, because on GuixSD systems that is the only program that
+# has a fixed file name. The second line is for editing this file in
+# Emacs. The next two lines below are valid code in both sh and perl.
+# When executed by sh, they re-execute the script through the perl
+# program found in $PATH. The '-x' option is essential; without it,
+# perl would re-execute the script through /bin/sh. When executed by
+# perl, the next two lines are a no-op.
+eval 'exec perl -wSx "$0" "$@"'
+ if 0;
+
# Generate a release announcement message.
my $VERSION = '2018-03-07 03:46'; # UTC
-eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
- & eval 'exec perl -wS "$0" $argv:q'
- if 0;
+#!/bin/sh
+#! -*-perl-*-
+# This is a prologue that allows to run a perl script as an executable
+# on systems that are compliant to a POSIX version before POSIX:2017.
+# On such systems, the usual invocation of an executable through execlp()
+# or execvp() fails with ENOEXEC if it is a script that does not start
+# with a #! line. The script interpreter mentioned in the #! line has
+# to be /bin/sh, because on GuixSD systems that is the only program that
+# has a fixed file name. The second line is for editing this file in
+# Emacs. The next two lines below are valid code in both sh and perl.
+# When executed by sh, they re-execute the script through the perl
+# program found in $PATH. The '-x' option is essential; without it,
+# perl would re-execute the script through /bin/sh. When executed by
+# perl, the next two lines are a no-op.
+eval 'exec perl -wSx "$0" "$@"'
+ if 0;
+
# Convert git log output to ChangeLog format.
my $VERSION = '2018-03-07 03:47'; # UTC
-eval '(exit $?0)' && eval 'exec perl -wS "$0" "$@"'
- & eval 'exec perl -wS "$0" $argv:q'
- if 0;
+#!/bin/sh
+#! -*-perl-*-
+# This is a prologue that allows to run a perl script as an executable
+# on systems that are compliant to a POSIX version before POSIX:2017.
+# On such systems, the usual invocation of an executable through execlp()
+# or execvp() fails with ENOEXEC if it is a script that does not start
+# with a #! line. The script interpreter mentioned in the #! line has
+# to be /bin/sh, because on GuixSD systems that is the only program that
+# has a fixed file name. The second line is for editing this file in
+# Emacs. The next two lines below are valid code in both sh and perl.
+# When executed by sh, they re-execute the script through the perl
+# program found in $PATH. The '-x' option is essential; without it,
+# perl would re-execute the script through /bin/sh. When executed by
+# perl, the next two lines are a no-op.
+eval 'exec perl -wSx "$0" "$@"'
+ if 0;
use strict;
use IO::File;
-eval '(exit $?0)' && eval 'exec perl -wS -0777 -pi "$0" "$@"'
- & eval 'exec perl -wS -0777 -pi "$0" $argv:q'
- if 0;
+#!/bin/sh
+#! -*-perl-*-
+# This is a prologue that allows to run a perl script as an executable
+# on systems that are compliant to a POSIX version before POSIX:2017.
+# On such systems, the usual invocation of an executable through execlp()
+# or execvp() fails with ENOEXEC if it is a script that does not start
+# with a #! line. The script interpreter mentioned in the #! line has
+# to be /bin/sh, because on GuixSD systems that is the only program that
+# has a fixed file name. The second line is for editing this file in
+# Emacs. The next two lines below are valid code in both sh and perl.
+# When executed by sh, they re-execute the script through the perl
+# program found in $PATH. The '-x' option is essential; without it,
+# perl would re-execute the script through /bin/sh. When executed by
+# perl, the next two lines are a no-op.
+eval 'exec perl -wSx "$0" "$@"'
+ if 0;
+
# Update an FSF copyright year list to include the current year.
my $VERSION = '2018-03-07.03:47'; # UTC
-eval '(exit $?0)' && eval 'exec perl -wST "$0" "$@"'
- & eval 'exec perl -wST "$0" $argv:q'
- if 0;
+#!/bin/sh
+#! -*-perl-*-
+# This is a prologue that allows to run a perl script as an executable
+# on systems that are compliant to a POSIX version before POSIX:2017.
+# On such systems, the usual invocation of an executable through execlp()
+# or execvp() fails with ENOEXEC if it is a script that does not start
+# with a #! line. The script interpreter mentioned in the #! line has
+# to be /bin/sh, because on GuixSD systems that is the only program that
+# has a fixed file name. The second line is for editing this file in
+# Emacs. The next two lines below are valid code in both sh and perl.
+# When executed by sh, they re-execute the script through the perl
+# program found in $PATH. The '-x' option is essential; without it,
+# perl would re-execute the script through /bin/sh. When executed by
+# perl, the next two lines are a no-op.
+eval 'exec perl -wSx "$0" "$@"'
+ if 0;
+
# Detect instances of "if (p) free (p);".
# Likewise "if (p != 0)", "if (0 != p)", or with NULL; and with braces.
TMP=$TMP_BASE
s=$TMP-script
cat <<\EOF > $s
-eval '(exit $?0)' && eval 'exec perl -wS -0777 -pi "$0" "$@"'
- & eval 'exec perl -wS -0777 -pi "$0" $argv:q'
- if 0;
+#!/bin/sh
+#! -*-perl-*-
+# This is a prologue that allows to run a perl script as an executable
+# on systems that are compliant to a POSIX version before POSIX:2017.
+# On such systems, the usual invocation of an executable through execlp()
+# or execvp() fails with ENOEXEC if it is a script that does not start
+# with a #! line. The script interpreter mentioned in the #! line has
+# to be /bin/sh, because on GuixSD systems that is the only program that
+# has a fixed file name. The second line is for editing this file in
+# Emacs. The next two lines below are valid code in both sh and perl.
+# When executed by sh, they re-execute the script through the perl
+# program found in $PATH. The '-x' option is essential; without it,
+# perl would re-execute the script through /bin/sh. When executed by
+# perl, the next two lines are a no-op.
+eval 'exec perl -wSx "$0" "$@"'
+ if 0;
+
s/a/b/
EOF
chmod a+x $s