]> Savannah Git Hosting - gnulib.git/commitdiff
tests/init.sh: exclude dash with bad "local" semantics
authorJim Meyering <meyering@fb.com>
Mon, 1 Aug 2016 16:37:15 +0000 (09:37 -0700)
committerJim Meyering <meyering@fb.com>
Mon, 8 Aug 2016 15:20:08 +0000 (08:20 -0700)
* tests/init.sh (gl_shell_test_script_): Add a function to
eliminate a shell like "dash" (unlike bash, zsh) that has
surprising/risky "local var='...'" semantics.  Inspired by
the problem and discussion in https://bugs.gnu.org/24116#11.

ChangeLog
tests/init.sh

index 7cfc6f73c9d47cc37c40481539cff3b01f4ba102..3bf441098a733f674d927f003c543d58df224268 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-08-06  Jim Meyering  <meyering@fb.com>
+
+       tests/init.sh: exclude dash with bad "local" semantics
+       * tests/init.sh (gl_shell_test_script_): Add a function to
+       eliminate a shell like "dash" (unlike bash, zsh) that has
+       surprising/risky "local var='...'" semantics.  Inspired by
+       the problem and discussion in https://bugs.gnu.org/24116#11.
+
 2016-08-02  Ján Tomko  <jtomko@redhat.com>
 
        maint.mk: expand the prohibit_doubled_word regex
index 97e4e4ba5e691ab04b376497cdddeabcf2cfa461..09b07394f9e90422f04e0d803cc651aef65d4748 100644 (file)
@@ -128,6 +128,13 @@ else
 fi
 
 # We require $(...) support unconditionally.
+# We require non-surprising "local" semantics (this eliminates dash).
+# This takes the admittedly draconian step of eliminating dash, because the
+# assignment tab=$(printf '\t') works fine, yet preceding it with "local "
+# transforms it into an assignment that sets the variable to the empty string.
+# That is too counter-intuitive, and can lead to subtle run-time malfunction.
+# The example below is less subtle in that with dash, it evokes the run-time
+# exception "dash: 1: local: 1: bad variable name".
 # We require a few additional shell features only when $EXEEXT is nonempty,
 # in order to support automatic $EXEEXT emulation:
 # - hyphen-containing alias names
@@ -151,6 +158,7 @@ fi
 gl_shell_test_script_='
 test $(echo y) = y || exit 1
 f_local_() { local v=1; }; f_local_ || exit 1
+f_dash_local_fail_() { local t=$(printf " 1"); }; f_dash_local_fail_
 score_=10
 if test "$VERBOSE" = yes; then
   test -n "$( (exec 3>&1; set -x; P=1 true 2>&3) 2> /dev/null)" && score_=9