summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2011-12-26 10:06:18 +0100
committerStefano Lattarini <stefano.lattarini@gmail.com>2011-12-26 22:09:34 +0100
commit8fb1aafa0d81175f3ca27ed7ed2e0532c8af9902 (patch)
tree6cdabc923432f625228acbd587ee2993b608b0b5
parentd1b31ac57cc069527d037f3291e643813ce0bd69 (diff)
downloadautoconf-8fb1aafa0d81175f3ca27ed7ed2e0532c8af9902.tar.gz
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.
-rw-r--r--ChangeLog7
-rw-r--r--lib/m4sugar/m4sh.m441
2 files changed, 33 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 8eaf0d7f..6fd538e1 100644
--- 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
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 7195618a..a92cd229 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -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
# -----------