From 88952495193d0d183a50de8c75b58e7c5bda7b91 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 2 Sep 2010 13:49:41 -0600 Subject: [PATCH] tests: init.sh improvements for re-exec'ing with zsh Tom's IRIX setup had a broken bash, and proceeded to run zsh outside of POSIX mode. But trying to trace that setup proved difficult, since the re-exec lost tracing. * tests/init.sh: Borrow autoconf POSIX-mode sanitization. Pass -vx through shell re-exec. Reported by Tom G. Christensen. Signed-off-by: Eric Blake --- ChangeLog | 5 +++++ tests/init.sh | 23 +++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72642d175..5be2ceb65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,11 @@ 2010-09-02 Eric Blake + tests: init.sh improvements for re-exec'ing with zsh + * tests/init.sh: Borrow autoconf POSIX-mode sanitization. Pass + -vx through shell re-exec. + Reported by Tom G. Christensen. + wctype: fix typo in previous commit * m4/wctype_h.m4 (gl_WCTYPE_H): Fix spelling. Reported by Ludovic Courtès. diff --git a/tests/init.sh b/tests/init.sh index bc82d69a9..fe2c22401 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -79,6 +79,19 @@ fail_() { warn_ "$ME_: failed test: $@"; Exit 1; } skip_() { warn_ "$ME_: skipped test: $@"; Exit 77; } framework_failure_() { warn_ "$ME_: set-up failure: $@"; Exit 99; } +# Sanitize this shell to POSIX mode, if possible. +DUALCASE=1; export DUALCASE +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; + esac +fi + # We require $(...) support unconditionally. # We require a few additional shell features only when $EXEEXT is nonempty, # in order to support automatic $EXEEXT emulation: @@ -122,8 +135,14 @@ else test "$re_shell_" = fail && skip_ failed to find an adequate shell "$re_shell_" -c "$gl_shell_test_script_" 2>/dev/null if test $? = 9; then - # Found an acceptable shell. - exec "$re_shell_" "$0" --no-reexec "$@" + # Found an acceptable shell. Preserve -v and -x. + case $- in + *v*x* | *x*v*) opts_=-vx ;; + *v*) opts_=-v ;; + *x*) opts_=-x ;; + *) opts_= ;; + esac + exec "$re_shell_" $opts_ "$0" --no-reexec "$@" echo "$ME_: exec failed" 1>&2 exit 127 fi -- 2.11.0