automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [FYI] {maint} tests: drop support for older Zsh shells


From: Stefano Lattarini
Subject: Re: [FYI] {maint} tests: drop support for older Zsh shells
Date: Sat, 23 Jun 2012 11:36:58 +0200

On 06/23/2012 11:19 AM, Stefano Lattarini wrote:
> * defs-static.in: Here.  The fact that such support has been broken for
> almost an year (only fixed by today's commit 'v1.12.1-57-gf1e0300'),
> causing no bug reports from anyone, shows that such support is not truly
> warranted.  And it will get in the way of future improvements in the
> handling of the exit trap (because bugs in older Zsh version will prevent
> some of our planned improvements).  So just drop it
> * t/README: Remove obsolete advices for older Zsh; instead, tell that we
> just don't support them.
> 
> Signed-off-by: Stefano Lattarini <address@hidden>
> ---
>  defs-static.in |   37 ++++++++++---------------------------
>  t/README       |   21 ++++-----------------
>  2 files changed, 14 insertions(+), 44 deletions(-)
> 
> diff --git a/defs-static.in b/defs-static.in
> index a902486..b0fba50 100644
> --- a/defs-static.in
> +++ b/defs-static.in
> @@ -31,35 +31,18 @@ DUALCASE=1; export DUALCASE # for MKS sh
>  if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
>    emulate sh
>    NULLCMD=:
> -  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
> -  # is contrary to our usage.  Disable this feature.
> -  alias -g '${1+"$@"}'='"$@"'
>    setopt NO_GLOB_SUBST
> -  # If Zsh is not started directly in Bourne-compatibility mode, it has
> -  # some incompatibilities in the handling of $0 that conflict with
> -  # our usage: i.e., $0 inside a file sourced with the '.' builtin is
> -  # temporarily 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>
> -  # Note: the apparently useless 'eval' below are needed by at least
> -  # dash 0.5.2, to prevent it from bailing out with an error like
> -  # "Syntax error: Bad substitution"
> -  if eval '[[ "$0" = *."tap" || "$0" = *."sh" ]]'; then
> -    # Good, FUNCTION_ARGZERO option was already off when this file was
> -    # sourced.  Thus we've nothing to do.
> -    argv0=$0
> -  elif eval 'test -n "${functrace[-1]}"'; then
> -    # FUNCTION_ARGZERO option was on, but we have a easy workaround.
> -    eval 'argv0=${functrace[-1]%:*}'
> -  else
> -    # Give up.
> -    echo "$0: cannot determine the path of running test script" >&2
> -    echo "$0: test was running with Zsh version $ZSH_VERSION" >&2
> -    echo "$0: did you enable the NO_FUNCTION_ARGZERO option?" >&2
> +  # If Zsh is not started directly in POSIX-compatibility mode, it has some
> +  # incompatibilities in the handling of $0 that conflict with our usage;
> +  # i.e., $0 inside a file sourced with the '.' builtin is temporarily set
> +  # to the name of the sourced file.  Work around that.  The apparently
> +  # useless 'eval' here is needed by at least dash 0.5.2, to prevent it
> +  # from bailing out with an error like "Syntax error: Bad substitution".
> +  eval 'argv0=${functrace[-1]%:*}' && test -f "$argv0" || {
> +    echo "Cannot determine the path of running test script." >&2
> +    echo "Your Zsh (version $ZSH_VERSION) is probably too old." >&2
>      exit 99
> -  fi
> +  }
>  else
>    argv0=$0
>    # Avoid command substitution failure, for Tru64 sh -e and instspc*.test.
> diff --git a/t/README b/t/README
> index 3f56400..409e833 100644
> --- a/t/README
> +++ b/t/README
> @@ -105,23 +105,10 @@ Supported shells
>    to run the test(s) through the makefile test driver.
>  
>    The test scripts are written with portability in mind, so that they
> -  should run with any decent Bourne-compatible shell.
> -
> -  However, some care must be used with Zsh, since, when not directly
> -  started in Bourne-compatibility mode, it has some incompatibilities
> -  in the handling of $0 which conflict with our usage.  Our testsuite
> -  can automatically work around these incompatibilities when a version
> -  4.3 or later of Zsh is used, but unfortunately not when an older
> -  version of Zsh is used.  Thus, if you want to run a test script, say
> -  'foo.sh', with Zsh 4.2, you *can't* simply do "zsh foo.sh", but
> -  you *must* resort to:
> -
> -    AM_TESTS_REEXEC=no zsh -o no_function_argzero foo.sh
> -
> -  Note that this problem does not occur if Zsh is executed through
> -  a symlink with a basename of 'sh', since in that case Zsh starts
> -  in Bourne compatibility mode.  So you should be perfectly safe
> -  when /bin/sh is Zsh, even a it's version < 4.3.
> +  should run with any decent Bourne-compatible shell.  However, it is
> +  worth nothing that older version of Zsh (pre-4.3) suffered of
> +  several bugs and incompatibilities with our usages, and are thus
> +  not supported.  Don't use the to run our tests!
>  
>  
>  Reporting failures
>
Hpmf, I've sent an incomplete version.  Consider this squashed in:

  diff --git a/defs-static.in b/defs-static.in
 index b0fba50..da5dcff 100644
  --- a/defs-static.in
  +++ b/defs-static.in
  @@ -35,9 +35,13 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 
2>&1; then
     # If Zsh is not started directly in POSIX-compatibility mode, it has some
     # incompatibilities in the handling of $0 that conflict with our usage;
     # i.e., $0 inside a file sourced with the '.' builtin is temporarily set
  -  # to the name of the sourced file.  Work around that.  The apparently
  -  # useless 'eval' here is needed by at least dash 0.5.2, to prevent it
  -  # from bailing out with an error like "Syntax error: Bad substitution".
  +  # to the name of the sourced file.  Work around that.
  +  # 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>
  +  # The apparently useless 'eval' here is needed by at least dash 0.5.2,
  +  # to prevent it from bailing out with an error like:
  +  #   "Syntax error: Bad substitution".
     eval 'argv0=${functrace[-1]%:*}' && test -f "$argv0" || {
       echo "Cannot determine the path of running test script." >&2
       echo "Your Zsh (version $ZSH_VERSION) is probably too old." >&2

Sorry for the noise,
  Stefano



reply via email to

[Prev in Thread] Current Thread [Next in Thread]