2003-11-25 Paolo Bonzini * lib/m4sugar/m4sh.m4 (_AS_BOURNE_COMPATIBLE): New macro, extracted from AS_SHELL_SANITIZE. (_AS_CHECK_FUNCTIONS_SUPPORT): New macro. (AS_SHELL_SANITIZE): Call _AS_BOURNE_COMPATIBLE and _AS_CHECK_FUNCTIONS_SUPPORT. (_AS_LINENO_PREPARE): Call _AS_CHECK_FUNCTIONS_SUPPORT. Index: lib/m4sugar/m4sh.m4 =================================================================== RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v retrieving revision 1.107 diff -u -r1.107 m4sh.m4 --- lib/m4sugar/m4sh.m4 24 Nov 2003 10:44:52 -0000 1.107 +++ lib/m4sugar/m4sh.m4 25 Nov 2003 12:46:53 -0000 @@ -147,14 +147,10 @@ }])])]) -# AS_SHELL_SANITIZE -# ----------------- +# _AS_BOURNE_COMPATIBLE +# --------------------- # Try to be as Bourne and/or POSIX as possible. -m4_defun([AS_SHELL_SANITIZE], -[## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## - +m4_define([_AS_BOURNE_COMPATIBLE], [ # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh @@ -166,7 +162,83 @@ set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh +]) + + +# _AS_CHECK_FUNCTIONS_SUPPORT(TESTED-SHELL, MESSAGE) +# -------------------------------------------------- +# This is a spy to detect "in the wild" shells that do not support +# shell functions correctly and that do support LINENO but not +# functions. It is based on the m4sh.at Autotest testcases. +m4_define([_AS_CHECK_FUNCTIONS_SUPPORT], +[$1 <<\EOF +_AS_BOURNE_COMPATIBLE +func_return () { + (exit [$]1) +} + +func_success () { + func_return 0 +} + +func_failure () { + func_return 1 +} + +func_ret_success () { + return 0 +} + +func_ret_failure () { + return 1 +} + +if func_success; then + if func_failure; then + cat </dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" dnl -]) + test "x$as_lineno_3" = "x$as_lineno_2"]) # _AS_LINENO_PREPARE # ------------------ @@ -579,6 +650,8 @@ AS_UNSET(BASH_ENV) AS_UNSET(ENV) CONFIG_SHELL=$as_dir/$as_base + _AS_CHECK_FUNCTIONS_SUPPORT([$CONFIG_SHELL], + [$CONFIG_SHELL supports LINENO but]) export CONFIG_SHELL exec "$CONFIG_SHELL" "$[0]" ${1+"address@hidden"} fi;; Index: tests/wrapper.in =================================================================== RCS file: /cvsroot/autoconf/autoconf/tests/wrapper.in,v retrieving revision 1.5 diff -u -r1.5 wrapper.in --- tests/wrapper.in 24 Nov 2003 09:09:06 -0000 1.5 +++ tests/wrapper.in 25 Nov 2003 12:46:54 -0000 @@ -3,6 +3,7 @@ ## M4sh Initialization. ## ## --------------------- ## + # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh @@ -14,6 +15,78 @@ set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh + +if test -z "$CONFIG_SHELL"; then + $SHELL <<\EOF + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi +DUALCASE=1; export DUALCASE # for MKS sh + +func_return () { + (exit $1) +} + +func_success () { + func_return 0 +} + +func_failure () { + func_return 1 +} + +func_ret_success () { + return 0 +} + +func_ret_failure () { + return 1 +} + +if func_success; then + if func_failure; then + cat </dev/null 2>&1; then