]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
More defense against bad echo
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 6 Aug 2024 17:00:26 +0000 (10:00 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 7 Aug 2024 00:59:36 +0000 (17:59 -0700)
* lib/autoconf/general.m4 (_AC_INIT_PARSE_ARGS)
(_AC_ARG_VAR_VALIDATE):
Defend against ‘echo’ interpreting ‘\’ or leading ‘-’.
(_AC_EVAL, _AC_EVAL_STDERR): Add to comment yet another reason
that these macros are obsolete and should be removed.  There’s no
point trying to change them as that’s more likely to hurt than
help the (zero?) callers who still use them.

lib/autoconf/general.m4

index 2dfa369141e2c9756ef707c6011693b8f0378bfc..20c688ed72bd172aa98a13ed07de6b4905d0d858 100644 (file)
@@ -930,7 +930,7 @@ Try '$[0] --help' for more information])
 done
 
 if test -n "$ac_prev"; then
-  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  ac_option=--`printf '%s\n' $ac_prev | sed 's/_/-/g'`
   AC_MSG_ERROR([missing argument to $ac_option])
 fi
 
@@ -1699,8 +1699,14 @@ for ac_var in $ac_precious_vars; do
     *)
       if test "x$ac_old_val" != "x$ac_new_val"; then
        # differences in whitespace do not lead to failure.
-       ac_old_val_w=`echo x $ac_old_val`
-       ac_new_val_w=`echo x $ac_new_val`
+       ac_old_val_w=
+       for ac_val in x $ac_old_val; do
+         ac_old_val_w="$ac_old_val_w $ac_val"
+       done
+       ac_new_val_w=
+       for ac_val in x $ac_new_val; do
+         ac_new_val_w="$ac_new_val_w $ac_val"
+       done
        if test "$ac_old_val_w" != "$ac_new_val_w"; then
          AS_MESSAGE([error: '$ac_var' has changed since the previous run:], 2)
          ac_cache_corrupted=:
@@ -2689,7 +2695,8 @@ AC_DEFUN([_AC_DO_LIMIT],
 # _AC_EVAL(COMMAND)
 # -----------------
 # Eval COMMAND, save the exit status in ac_status, and log it.
-# Unlike _AC_DO, this macro mishandles quoted arguments in some cases.
+# Unlike _AC_DO, this macro mishandles quoted arguments
+# and backslashes in some cases.
 # It is present only for backward compatibility with previous Autoconf versions.
 AC_DEFUN([_AC_EVAL],
 [_AC_RUN_LOG([eval $1],
@@ -2699,7 +2706,8 @@ AC_DEFUN([_AC_EVAL],
 # _AC_EVAL_STDERR(COMMAND)
 # ------------------------
 # Like _AC_RUN_LOG_STDERR, but eval (instead of running) COMMAND.
-# Unlike _AC_DO_STDERR, this macro mishandles quoted arguments in some cases.
+# Unlike _AC_DO_STDERR, this macro mishandles quoted arguments
+# and backslashes in some cases.
 # It is present only for backward compatibility with previous Autoconf versions.
 AC_DEFUN([_AC_EVAL_STDERR],
 [_AC_RUN_LOG_STDERR([eval $1],