* lib/m4sugar/m4sh.m4 (_AS_SHELL_NULL_WORKS, _AS_SHELL_NULL_SPY): New macros. (AS_INIT): Use it.
Signed-off-by: Eric Blake <[email protected]> --- This is the cautious alternative. If we go with this patch, then 2.68 will be released without any use of ${a:<op>b} (for <op> in -, +, =, ?), except for the spy; and assuming no bug reports, then 2.69 can go ahead and use it at will by deleting _AS_SHELL_NULL_SPY and by moving _AS_SHELL_NULL_WORKS from _AS_DETECT_SUGGESTED over to _AS_DETECT_REQUIRED. The more aggressive approach is to assume that all shells that support shell functions also support : in variable substitutions; this is the approach we ended up using for unset and for [!..] pattern negation in globbing. If we go with the more aggressive approach, I wonder how many locations within autoconf we can find that would benefit from a size reduction by relying on :. Should we also update tests/m4sh.at to add a test next to 'Negated classes in globbing' and 'Functions support' to reiterate this spy in the autoconf testsuite? Preferences on whether we should be conservative or more aggressive? ChangeLog | 5 +++++ lib/m4sugar/m4sh.m4 | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index e82f811..6dc702b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-08-24 Eric Blake <[email protected]> + m4sh: detect any shell that lacks ${a:-b} support + * lib/m4sugar/m4sh.m4 (_AS_SHELL_NULL_WORKS, _AS_SHELL_NULL_SPY): + New macros. + (AS_INIT): Use it. + AC_FUNC_GETLOADAVG: don't define SVR4 on cygwin * lib/autoconf/functions.m4 (_AC_LIBOBJ_GETLOADAVG): Only define SVR4 when -lkvm is required. diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4 index 3cc868c..661f43a 100644 --- a/lib/m4sugar/m4sh.m4 +++ b/lib/m4sugar/m4sh.m4 @@ -403,6 +403,28 @@ AS_IF([( set x; as_fn_ret_success y && test x = "[$]1" )], [], [exitcode=1; echo positional parameters were not saved.]) test x$exitcode = x0[]])# _AS_SHELL_FN_WORK +# _AS_SHELL_NULL_WORKS +# -------------------- +# This is a spy to detect "in the wild" shells that do not support null +# variable manipulation correctly. It is assumed that all shells that +# support functions also support colons in variable substitution. +m4_define([_AS_SHELL_NULL_WORKS], +[as_var=; test "${as_var:-empty}" = empty])# _AS_SHELL_NULL_WORKS + +# _AS_SHELL_NULL_SPY +# ------------------ +# This temporary macro checks "in the wild" for shells that do not support +# null variable manipulation. FIXME: remove in the next release after 2.68. +m4_defun([_AS_SHELL_NULL_SPY], +[_AS_DETECT_SUGGESTED([_AS_SHELL_NULL_WORKS]) +_AS_RUN([_AS_SHELL_NULL_WORKS]) || { + echo No shell found that supports \${a:-b}. + echo Please tell [email protected] about your system, + echo including any error possibly output before this message. + echo This can help us improve future autoconf versions. + echo Configuration will now proceed without null variable substitution. +} +]) # _AS_SHELL_SANITIZE # ------------------ @@ -2124,6 +2146,7 @@ m4_divert_text([HEADER-COMMENT], [...@%:@ Generated from __file__ by m4_PACKAGE_STRING.]) m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE]) m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])]) +AS_REQUIRE([_AS_SHELL_NULL_SPY]) # Let's go! m4_divert([BODY])dnl -- 1.7.2.1
