]> Savannah Git Hosting - gnulib.git/commitdiff
Fix scripts to have valid executable format on Alpine Linux.
authorBruno Haible <bruno@clisp.org>
Sat, 15 Jun 2019 11:03:58 +0000 (13:03 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 15 Jun 2019 11:06:55 +0000 (13:06 +0200)
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.

ChangeLog
build-aux/announce-gen
build-aux/gitlog-to-changelog
build-aux/prefix-gnulib-mk
build-aux/update-copyright
build-aux/useless-if-before-free
tests/test-update-copyright.sh

index 18aecf7d2de5786f35bff8cd91a02748e4700246..a0d2f415fee86330d40e48ff0a54a8fa80d60b9d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+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.
index 0174f5c8d1ad3c500f623bbd45aba737348ed2f1..b5728338c797936a06e2a6161e092638fddcb349 100755 (executable)
@@ -1,6 +1,20 @@
-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
index deddef24466eb6b0d8ff695c5d6504df8ed647c8..a616b82343626d093cae28631a3d1ec8df713c96 100755 (executable)
@@ -1,6 +1,20 @@
-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
index bef726f6bbbd28abfb534a02d6ac59cba4c78dde..66e138b46fcec77191e19e8845048c91b14c8ccd 100755 (executable)
@@ -1,6 +1,19 @@
-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;
index d80549ea8dd3b3bf4dd65263c845426af294480b..fa9d427e924c4b3a7ce21e76dfe400b20513e050 100755 (executable)
@@ -1,6 +1,20 @@
-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
index 6d6b8d4199ae98ce1631eb25ec08df71aa32fa13..0701e7b20b8701b775f5eb9bd70e40bfe2b4b853 100755 (executable)
@@ -1,6 +1,20 @@
-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.
 
index f270db5d3bc7c66bb98037d58cc47afd096069a8..9ef5344eadcf40118a27906a8ef560b3f94d8a8f 100755 (executable)
@@ -37,9 +37,23 @@ trap 'rm -f $TMP_BASE*' 0 1 2 3 15
 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