Ping? (In the meantime, I rebased the patch against the latest master branch).
Regards, Stefano
From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: 2009-12-26 02:08:36 2009 +0100 Subject: [PATCH] Work around Zsh incompatibility w.r.t handling `$0' (testsuite related) * tests/README (Supported shells): When describing the manual workaround about the Zsh incompatibility w.r.t the handling of the special variable `$0', tell that it is now needed only with Zsh3. * tests/defs.in: For Zsh4, work around the incompatibility in the way Zsh deal with the special variable `$0' (the workaround uses the Zsh special variable `$functrace'). For Zsh 3, abort the script if the option `FUNCTION_ARGZERO' is on. --- ChangeLog | 14 ++++++++++++++ tests/README | 12 +++++++----- tests/defs.in | 33 ++++++++++++++++++++++++++++----- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e0f5b4..79b2bb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2009-12-26 Stefano Lattarini <stefano.lattar...@gmail.com> + + In the testsuite: try to work around Zsh incompatibility w.r.t + the handling of the special variable `$0'. + * tests/README (Supported shells): When describing the manual + workaround about the Zsh incompatibility w.r.t the handling of + the special variable `$0', tell that it is now needed only with + Zsh3. + * tests/defs.in: For Zsh4, work around the incompatibility in the + way Zsh deal with the special variable `$0' (the workaround uses + the Zsh special variable `$functrace'). + For Zsh 3, abort the script if the option `FUNCTION_ARGZERO' is + on. + 2009-12-05 Antonio Diaz Diaz <ant_d...@teleline.es> Replace unlzma, gunzip, bunzip2 with pack tool -d invocation. diff --git a/tests/README b/tests/README index d494b10..577686a 100644 --- a/tests/README +++ b/tests/README @@ -71,16 +71,18 @@ Supported shells However, some care must be used with Zsh, since, when not directly starting in Bourne-compatibility mode, it has some incompatibilities - in the handling of `$0' which conflict with our usage, and which have - no easy workaround. Thus, if you want to run a test script, say - foo.test, with Zsh, you *can't* simply do `zsh foo.test', but you + in the handling of `$0' which conflict with our usage. Our testsuite + can automatically work around these incompatibilities when a version + 4.x or later of Zsh is used, but unfortunately not when an older (3.x) + version of Zsh is used. Thus, if you want to run a test script, say + foo.test, with Zsh 3.x, you *can't* simply do `zsh foo.test', but you *must* resort to: zsh -o no_function_argzero foo.test - Note that this problem does not occur if zsh is executed through a + Note that this problem does not occur if Zsh is executed through a symlink with a basename of `sh', since in that case it starts in Bourne compatibility mode. So you should be perfectly safe when - /bin/sh is zsh. + /bin/sh is zsh, even a it's only a 3.x version. Reporting failures diff --git a/tests/defs.in b/tests/defs.in index 6eec344..9d40b03 100644 --- a/tests/defs.in +++ b/tests/defs.in @@ -21,7 +21,7 @@ # Tom Tromey <tro...@cygnus.com> # Be more Bourne compatible. -# (Snippet copied from configure's initialization in Autoconf 2.64) +# (Snippet inspired to configure's initialization in Autoconf 2.64) DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh @@ -30,7 +30,30 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST + # Zsh, when not directly starting in Bourne-compatibility mode, has some + # incompatibilities in the handling of `$0' which conflict with our usage + # (e.g., `$0' inside a file sourced with the `.' builtin is temporarly + # set to the name of the sourced file). Work around this when possible, + # otherwise abort the script. + # Note that a bug in some versions of Zsh prevents us from resetting $0 + # in a sourced script, so the use of $argv0. For more info see: + # <http://www.zsh.org/mla/workers/2009/msg01140.html> + if [[ "$0" = *.'test' ]]; then + # Good, FUNCTION_ARGZERO option was already off when this file was + # sourced. Thus we've nothing to do. + argv0=$0 + elif test -n "${functrace[-1]}"; then + # FUNCTION_ARGZERO option was on, but we have a easy workaround. + argv0=${functrace[-1]%:*} + else + # Give up. + echo "$0: (Zsh version $ZSH_VERSION) cannot determine the" \ + "path of running test script" >&2 + echo "$0:$LINENO: *** ABORT ***" >&2 + exit 99 + fi else + argv0=$0 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi @@ -42,8 +65,8 @@ test -f ./defs || { if test -z "$srcdir"; then # compute $srcdir. - srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'` - test "$srcdir" = $0 && srcdir=. + srcdir=`echo "$argv0" | sed -e 's,/[^\\/]*$,,'` + test "$srcdir" = $argv0 && srcdir=. else :; fi # Ensure $srcdir is set correctly. @@ -52,7 +75,7 @@ test -f "$srcdir/defs.in" || { exit 1 } -me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'` +me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.test$//'` # Make sure we override the user shell. SHELL='@SHELL@' @@ -321,7 +344,7 @@ unset TEST_LOGS unset RECHECK_LOGS unset VERBOSE -echo "=== Running test $0" +echo "=== Running test $argv0" # We might need extra macros, e.g., from Libtool or Gettext. # Find them on the system. -- 1.6.5