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 <