Jim Meyering wrote: > Andreas Schwab wrote: >> Jim Meyering <[email protected]> writes: >> >>> For the record, I reduced it to this, >>> where /bin/sh is /usr/local/bin/bash, which is 4.1.7: > > Actually, /bin/sh is *not* bash on that particular system. > Rather, it's simply FreeBSD 8.1's /bin/sh. > That requires a more general work-around... > >>> cat <<\EOF > init.cfg >>> f() >>> { >>> case $IFS in '') exit 91;; esac >>> local s=$IFS >>> case $s in '') exit 97;; esac >>> } >>> f >>> EOF >>> $ /bin/sh -c '. init.cfg' >>> [Exit 97] >> >> Perhaps local isn't really the builtin local? > > $ /bin/sh -c 'type local' > local is a shell builtin > > Here's a better test case: > > $ /bin/sh -c 'f(){ local s=$IFS; test -n "$s"; }; f' > [Exit 1] > > And based on that, here's a patch to gnulib's tests/init.sh > that solves the problem more generally: > (but this is not enough for coreutils, since some > failing tests don't yet use init.sh) > ... > gl_shell_test_script_=' > test $(echo y) = y || exit 1 > +f(){ local s=$IFS; test -n "$s"; }; f || exit 1
Cc'ing bug-gnulib. This started with a coreutils thread: http://thread.gmane.org/gmane.comp.gnu.coreutils.general/436/focus=438 Using a bare "f" there would be asking for trouble. The adjusted patch below uses gl_local_test_ instead. >From 99db7b4e62db9604b71c2fc3de56426d9ab346cf Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sat, 6 Nov 2010 14:43:08 +0100 Subject: [PATCH] init.sh: disqualify FreeBSD 8.1's /bin/sh * tests/init.sh: Arrange not to accept FreeBSD 8.1's /bin/sh, since it fails this test: /bin/sh -c 'f(){ local s=$IFS; test -n "$s"; }; f' --- ChangeLog | 6 ++++++ tests/init.sh | 4 ++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index e36599e..bc198e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-11-06 Jim Meyering <[email protected]> + + init.sh: disqualify FreeBSD 8.1's /bin/sh + * tests/init.sh: Arrange not to accept FreeBSD 8.1's /bin/sh, since + it fails this test: /bin/sh -c 'f(){ local s=$IFS; test -n "$s"; }; f' + 2010-11-05 Eric Blake <[email protected]> ceil, floor: avoid spurious failure with icc diff --git a/tests/init.sh b/tests/init.sh index a57de77..0193cbe 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -93,6 +93,9 @@ else fi # We require $(...) support unconditionally. +# We also require "local" support. The local-vs-IFS test is required to +# eliminate FreeBSD 8.1's /bin/sh, which would otherwise pass these tests +# and provoke opaque test failures in coreutils. # We require a few additional shell features only when $EXEEXT is nonempty, # in order to support automatic $EXEEXT emulation: # - hyphen-containing alias names @@ -115,6 +118,7 @@ fi # ? - not ok gl_shell_test_script_=' test $(echo y) = y || exit 1 +gl_local_test_(){ local s=$IFS; test -n "$s"; }; gl_local_test_ || exit 1 score_=10 if test "$VERBOSE" = yes; then test -n "$( (exec 3>&1; set -x; P=1 true 2>&3) 2> /dev/null)" && score_=9 -- 1.7.3.2.193.g78bbb
