Hello automakers. Since I'm rebasing some other patch series agains master, I took the opportunity to do the same with this simpler patch, also amending it to properly bump copyright years in the modified file. These are just very minor changes over the previous patch.
Please let me now if you find this continuous tweaking and updating of patches annoying. Regards, Stefano
From 11e3aeec48df498c43d890f7f9b2891e734dd98d Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Sat, 30 Jan 2010 14:01:39 +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. Also, updated copyright years. --- ChangeLog | 15 +++++++++++++++ tests/README | 12 +++++++----- tests/defs.in | 35 +++++++++++++++++++++++++++++------ 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index da01f8f..d2ed643 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-01-30 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. + Also, updated copyright years. + 2010-01-24 Ralf Wildenhues <ralf.wildenh...@gmx.de> Fix silent-rules output for disabled dependency tracking. 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..cf031c9 100644 --- a/tests/defs.in +++ b/tests/defs.in @@ -2,7 +2,7 @@ # @configure_input@ # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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