]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
m4sh: refactor _AS_DETECT_BETTER_SHELL, for future changes
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 26 Dec 2011 09:06:18 +0000 (10:06 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 26 Dec 2011 21:09:34 +0000 (22:09 +0100)
* lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Move code to
handle the re-execution of the shell ...
(_AS_REEXEC_WITH_SHELL): ... in this new macro.

ChangeLog
lib/m4sugar/m4sh.m4

index 8eaf0d7ff192ea736f6d3439d81be87d5f482321..6fd538e156c30eaea59d652efc15062be3a9fbe2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-12-26  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       m4sh: refactor _AS_DETECT_BETTER_SHELL, for future changes
+       * lib/m4sugar/m4sh.m4 (_AS_DETECT_BETTER_SHELL): Move code to
+       handle the re-execution of the shell ...
+       (_AS_REEXEC_WITH_SHELL): ... in this new macro.
+
 2011-12-24  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        docs: issue with shell functions and here-documents on Solaris
index 7195618a28ca8bf132e38c580a7c1b7943c0bcef..a92cd229cb0b4f6ca36b1ee37239676c8ad731c0 100644 (file)
@@ -223,21 +223,8 @@ dnl Remove any tests from suggested that are also required
             [CONFIG_SHELL=$SHELL as_have_required=yes])])
 
       AS_IF([test "x$CONFIG_SHELL" != x],
-       [# We cannot yet assume a decent shell, so we have to provide a
-       # neutralization value for shells without unset; and this also
-       # works around shells that cannot unset nonexistent variables.
-       # Preserve -v and -x to the replacement shell.
-       BASH_ENV=/dev/null
-       ENV=/dev/null
-       (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-       export CONFIG_SHELL
-       case $- in @%:@ ((((
-         *v*x* | *x*v* ) as_opts=-vx ;;
-         *v* ) as_opts=-v ;;
-         *x* ) as_opts=-x ;;
-         * ) as_opts= ;;
-       esac
-       exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$[@]"}])
+            [export CONFIG_SHELL
+             _AS_REEXEC_WITH_SHELL([$CONFIG_SHELL])])
 
 dnl Unfortunately, $as_me isn't available here.
     AS_IF([test x$as_have_required = xno],
@@ -263,6 +250,30 @@ CLICOLOR_FORCE= GREP_OPTIONS=
 unset CLICOLOR_FORCE GREP_OPTIONS
 _m4_popdef([AS_EXIT])])# _AS_DETECT_BETTER_SHELL
 
+# _AS_REEXEC_WITH_SHELL(SHELL)
+# ----------------------------
+# Re-execute the current script with the given shell, trying to preserve
+# portable settings (e.g., the `xtrace' and `verbose' shell flag).
+m4_defun([_AS_REEXEC_WITH_SHELL], [dnl
+# We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in @%:@ ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $1 $as_opts "$as_myself" ${1+"$[@]"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+AS_ECHO(["$[]0: could not re-execute with $1"]) >&2
+AS_EXIT([255])])# _AS_REEXEC_WITH_SHELL
+
 
 # _AS_PREPARE
 # -----------