diff options
-rw-r--r-- | configure.ac | 41 | ||||
-rw-r--r-- | tests/atlocal.in | 2 | ||||
-rw-r--r-- | tests/local.at | 6 | ||||
-rw-r--r-- | tests/tools.at | 2 |
4 files changed, 31 insertions, 20 deletions
diff --git a/configure.ac b/configure.ac index 8ff9f729..e9f0da92 100644 --- a/configure.ac +++ b/configure.ac @@ -35,9 +35,9 @@ AC_SUBST([RELEASE_YEAR]) AB_INIT -# We use '/bin/sh -n script' to check that there are no syntax errors -# in the scripts. Although incredible, there are /bin/sh that go into -# endless loops with '-n', e.g., SunOS's: +# We use 'sh -n script' to check that there are no syntax errors +# in the scripts. Although incredible, there are sh implementations +# that go into endless loops with '-n', e.g., SunOS's: # # $ uname -a # SunOS ondine 4.1.3 2 sun4m unknown @@ -52,27 +52,38 @@ AB_INIT # $ time sh -nx endless.sh # ^Csh -nx endless.sh 3,67s user 0,03s system 63% cpu 5,868 total # -# Also, some implementations of /bin/sh (e.g., Solaris 8) are soooo slow +# Also, some implementations (e.g., Solaris 8) are soooo slow # that they are unusable on large scripts like our testsuite. - -# So before using '/bin/sh -n' to check our scripts, we first check -# that '/bin/sh -n' is known to not have these problems. - -AC_CACHE_CHECK([whether /bin/sh -n is known to work], [ac_cv_sh_n_works], -[if ( +# +# So we must identify a shell whose -n can safely be used. + +AC_CACHE_CHECK([for a shell whose -n mode is known to work], + [ac_cv_sh_working_n], +[ac_cv_sh_working_n=none +# Start by trying the shell that autoconf decided to use for this script, +# follow with a hardwired list of shells that are known to work and can +# be identified as such, starting with the ones with the fewest +# syntactic extensions. Unfortunately, several shells that are also +# known to work can't be easily identified (e.g. BSD sh, dash). +# Try ksh93, which is often buggy, and plain ksh and sh last. +for cand_sh in "$SHELL" pdksh bash zsh ksh93 ksh sh +do + if ( unset BASH_VERSION ZSH_VERSION - /bin/sh -c ' + "$cand_sh" -c ' test ${BASH_VERSION+y} || # Bash test ${KSH_VERSION+y} || # pdksh test ${ZSH_VERSION+y} || # zsh test -n "${.sh.version}" # ksh93; put this last since its syntax is dodgy ' ) 2>/dev/null -then ac_cv_sh_n_works=yes -else ac_cv_sh_n_works=no -fi + then + ac_cv_sh_working_n="$cand_sh" + break + fi +done ]) -AC_SUBST([ac_cv_sh_n_works]) +AC_SUBST([SHELL_N], [$ac_cv_sh_working_n]) AC_MSG_CHECKING([for characters that cannot appear in file names]) AC_CACHE_VAL([ac_cv_unsupported_fs_chars], diff --git a/tests/atlocal.in b/tests/atlocal.in index ec2a4167..079e35c6 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -24,7 +24,7 @@ EGREP='@EGREP@' SED='@SED@' # We need to know if sh -n is ok. -ac_cv_sh_n_works='@ac_cv_sh_n_works@' +SHELL_N='@SHELL_N@' # Check whether the underlying system can manage some unusual # symbols in file names. diff --git a/tests/local.at b/tests/local.at index 88a24e77..8496f55c 100644 --- a/tests/local.at +++ b/tests/local.at @@ -50,8 +50,8 @@ AT_CHECK([$at_diff "$1" "$2"]) # otherwise, do nothing. ksh93 -n also spits outs loads of warnings # about older constructs, but we don't care about the warnings. m4_define([AT_CHECK_SHELL_SYNTAX], -[AT_SKIP_IF([test "$ac_cv_sh_n_works" != yes]) -AT_CHECK([/bin/sh -n $1], [], [], [ignore])]) +[AT_SKIP_IF([test "$SHELL_N" = none]) +AT_CHECK(["$SHELL_N" -n $1], [], [], [ignore])]) m4_define([AT_CHECK_PERL_SYNTAX], [AT_CHECK([autom4te_perllibdir=$abs_top_srcdir/lib $PERL -c "$abs_top_builddir"/bin/$1], @@ -216,7 +216,7 @@ cp "$abs_top_srcdir/tests/statesave.m4" aclocal.m4 # were running too fast. m4_define([AT_CHECK_AUTOCONF], [AT_CHECK_M4([autoconf --force $1], [$2], [$3], [$4]) -if test -s configure && test "$ac_cv_sh_n_works" = yes; then +if test -s configure && test "$SHELL_N" != none; then AT_CHECK_SHELL_SYNTAX([configure]) fi ]) diff --git a/tests/tools.at b/tests/tools.at index b95bdcf5..9d3c7183 100644 --- a/tests/tools.at +++ b/tests/tools.at @@ -45,7 +45,7 @@ AT_BANNER([Executables (autoheader, autoupdate...).]) AT_SETUP([Syntax of the shell scripts]) -AT_CHECK([test "$ac_cv_sh_n_works" = yes || exit 77]) +AT_CHECK([test "$SHELL_N" != none || exit 77]) # Specify the absolute name of the tool, as some shells don't honor PATH when # running `sh PROG'. |