>From c95615dae1f4427f7f38efed4db1ddea64491328 Mon Sep 17 00:00:00 2001 Message-Id: From: Stefano Lattarini Date: Mon, 26 Dec 2011 10:06:18 +0100 Subject: [PATCH 1/3] 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. --- ChangeLog | 7 +++++++ lib/m4sugar/m4sh.m4 | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f67f89..1e9fdce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-12-26 Stefano Lattarini + + 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-07 Paul Eggert AC_LANG_BOOL_COMPILE_TRY(C): port to g++ with warnings diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 1ff1705..a0c9b1f 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+"address@hidden"}]) + [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+"address@hidden"} +# 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 # ----------- -- 1.7.7.3