]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
m4sh: Require shell to support $(...) command substitution.
authorZack Weinberg <zackw@panix.com>
Mon, 9 Nov 2020 20:15:23 +0000 (15:15 -0500)
committerZack Weinberg <zackw@panix.com>
Mon, 9 Nov 2020 20:15:23 +0000 (15:15 -0500)
As of the 2020-11-07 update, config.sub and config.guess
unconditionally use $(...) command substitution; see
<https://lists.gnu.org/archive/html/config-patches/2020-11/msg00011.html>.

Therefore, add this to the set of required shell features, searched
for by _AS_DETECT_BETTER_SHELL.  On a system where /bin/sh doesn’t
support $(...), $CONFIG_SHELL will be set to one that does (and the
primary configure script will be re-executed using that shell).
AC_CANONICAL_* use $CONFIG_SHELL to execute config.guess/sub, so they
will keep working.  This also means that configure scripts and
third-party macros that use $(...) will quietly start working
correctly on such ancient systems.

The test code is simple, but sufficient to weed out Solaris 10’s
/bin/sh, which doesn’t support $(...) but *does* support shell
functions.

I’m not going to touch any of the existing uses of `...` command
substitution in Autoconf proper for now, but it might make sense to
bulk upgrade them early in the 2.71 release cycle; if nothing else,
it would remove a major obstacle to running shellcheck over our
scripts.

* lib/m4sugar/m4sh.m4 (_AS_MODERN_CMDSUBST_WORKS): New macro.
  (AS_INIT, AS_SHELL_SANITIZE): Call _AS_DETECT_REQUIRED for
  _AS_MODERN_CMDSUBST_WORKS.
* NEWS: Mention the requirement for $(...).

NEWS
lib/m4sugar/m4sh.m4

diff --git a/NEWS b/NEWS
index da095533f1bf276ab8f370af42267117f57fdf39..5994d6be94e7a332ae13b9d4a6bccfb418634ede 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -116,6 +116,19 @@ GNU Autoconf NEWS - User visible changes.
   old, and unlikely to be able to handle modern C programs for other
   reasons (e.g. not having a C90-compliant compiler at all).
 
+*** Configure scripts require support for $( ... ) command substitution.
+
+  This POSIX shell feature is approximately the same age as
+  user-defined functions, but there do exist shells that support
+  functions and not $( ... ), such as Solaris 10 /bin/sh.
+
+  Configure scripts will automatically locate a shell that supports
+  this feature and re-execute themselves with it, if necessary, so
+  the new requirement should be transparent to most users.
+
+  In this release, most of Autoconf’s code still uses the older `...`
+  notation for command substitution.
+
 *** AC_INIT now trims extra white space from its arguments.
 
   For instance, AC_INIT([  GNU  Hello  ], [1.0]) will set PACKAGE_NAME
index a1c1cd475cff2b61f945cd024b617231664cff89..8f96eb7bccd07402def3fb225439dedd555ac1a4 100644 (file)
@@ -468,6 +468,15 @@ AS_IF([( set x; as_fn_ret_success y && test x = "[$]1" )], [],
 test x$exitcode = x0[]])# _AS_SHELL_FN_WORK
 
 
+# _AS_MODERN_CMDSUBST_WORKS
+# -------------------------
+# This is a spy to detect "in the wild" shells that do not support
+# the newer $(...) form of command substitutions.
+m4_define([_AS_MODERN_CMDSUBST_WORKS],
+[blah=$(echo $(echo blah))
+test x"$blah" = xblah])
+
+
 # _AS_SHELL_SANITIZE
 # ------------------
 # This is the prolog that is emitted by AS_INIT and AS_INIT_GENERATED;
@@ -544,6 +553,7 @@ m4_define([AS_SHELL_SANITIZE],
 m4_provide_if([AS_INIT], [],
 [m4_provide([AS_INIT])
 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])
+_AS_DETECT_REQUIRED([_AS_MODERN_CMDSUBST_WORKS])
 _AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])
 _AS_DETECT_BETTER_SHELL
 _AS_UNSET_PREPARE
@@ -2177,6 +2187,7 @@ m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])])
 m4_divert([BODY])dnl
 m4_text_box([Main body of script.])
 _AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
+_AS_DETECT_REQUIRED([_AS_MODERN_CMDSUBST_WORKS])dnl
 _AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])dnl
 AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl
 ])