]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Avoid some echo '...\...' gotchas
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 21 Oct 2024 17:49:30 +0000 (10:49 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 21 Oct 2024 17:50:25 +0000 (10:50 -0700)
Problem with AC_SUBST_FILE reported by Dylan Palauzov in:
https://lists.gnu.org/r/bug-autoconf/2024-10/msg00018.html
The other problems I found by a manual scan.
* bootstrap: Use printf, not echo.
* doc/autoconf.texi (Polymorphic Variables):
* lib/autoconf/fortran.m4 (_AC_PROG_FC_V_OUTPUT):
* lib/autoconf/general.m4 (_AC_CANONICAL_SPLIT):
* lib/autoconf/status.m4 (_AC_SUBST_FILES):
* lib/autotest/general.m4 (AT_FINISH):
Use AS_ECHO, not echo.

bootstrap
doc/autoconf.texi
lib/autoconf/fortran.m4
lib/autoconf/general.m4
lib/autoconf/status.m4
lib/autotest/general.m4

index b2da1a0c8571f2115959eb5bb1f71f35d6225cb7..700ec25d12f2941dde657cfe5c3e654b6c15c263 100755 (executable)
--- a/bootstrap
+++ b/bootstrap
@@ -158,19 +158,22 @@ PACKAGE_BUGREPORT=$(sed -n < configure.ac \
    -e 's/^m4_define(\[autoconf_PACKAGE_BUGREPORT], \[\([^]]*\)])$/\1/p')
 
 if [ -z "$RELEASE_YEAR" ]; then
-    echo "$me: error: could not extract RELEASE_YEAR from configure.ac" >&2
+    printf >&2 '%s\n' \
+      "$me: error: could not extract RELEASE_YEAR from configure.ac"
     exit 1
 fi
 if [ -z "$VERSION" ]; then
-    echo "$me: error: could not compute VERSION" >&2
+    printf >&2 '%s\n' "$me: error: could not compute VERSION"
     exit 1
 fi
 if [ -z "$PACKAGE_NAME" ]; then
-    echo "$me: error: could not extract PACKAGE_NAME from configure.ac" >&2
+    printf >&2 '%s\n' \
+      "$me: error: could not extract PACKAGE_NAME from configure.ac"
     exit 1
 fi
 if [ -z "$PACKAGE_BUGREPORT" ]; then
-    echo "$me: error: could not extract PACKAGE_BUGREPORT from configure.ac" >&2
+    printf >&2 '%s\n' \
+      "$me: error: could not extract PACKAGE_BUGREPORT from configure.ac"
     exit 1
 fi
 
index fd7e9ab09c7d1324399f84bdc42d9373a0a468bb..565f4da349fc2336b1d2dfb9657ca6c4f129ab15 100644 (file)
@@ -14257,7 +14257,7 @@ copy the contents into a temporary literal shell variable.
 @smallexample
 for header in stdint_h inttypes_h ; do
   AS_VAR_COPY([var], [ac_cv_header_$header])
-  echo "$header detected: $var"
+  AS_ECHO(["$header detected: $var"])
 done
 @end smallexample
 @end defmac
index 627adf8aff9c52bded3a3fa1b3d3c0de511a4a3b..c994a76a872bab9020207b3d323031d69ef6b3b2 100644 (file)
@@ -522,9 +522,9 @@ rm -rf conftest*
 # On HP/UX there is a line like: "LPATH is: /foo:/bar:/baz" where
 # /foo, /bar, and /baz are search directories for the Fortran linker.
 # Here, we change these into -L/foo -L/bar -L/baz (and put it first):
-ac_[]_AC_LANG_ABBREV[]_v_output="`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
+ac_[]_AC_LANG_ABBREV[]_v_output=`AS_ECHO(["$ac_[]_AC_LANG_ABBREV[]_v_output"])|
        grep 'LPATH is:' |
-       sed 's|.*LPATH is\(: *[[^ ]]*\).*|\1|;s|: */| -L/|g'` $ac_[]_AC_LANG_ABBREV[]_v_output"
+       sed 's|.*LPATH is\(: *[[^ ]]*\).*|\1|;s|: */| -L/|g'`" $ac_[]_AC_LANG_ABBREV[]_v_output"
 
 # FIXME: we keep getting bitten by quoted arguments; a more general fix
 #        that detects unbalanced quotes in FLIBS should be implemented
@@ -533,7 +533,7 @@ case $ac_[]_AC_LANG_ABBREV[]_v_output in
   # With xlf replace commas with spaces,
   # and remove "-link" and closing parenthesis.
   *xlfentry*)
-    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output |
+    ac_[]_AC_LANG_ABBREV[]_v_output=`AS_ECHO(["$ac_[]_AC_LANG_ABBREV[]_v_output"]) |
       sed '
         s/,/ /g
         s/ -link / /g
@@ -544,20 +544,20 @@ case $ac_[]_AC_LANG_ABBREV[]_v_output in
   # With Intel ifc, ignore the quoted -mGLOB_options_string stuff (quoted
   # $LIBS confuse us, and the libraries appear later in the output anyway).
   *mGLOB_options_string*)
-    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/"-mGLOB[[^"]]*"/ /g'` ;;
+    ac_[]_AC_LANG_ABBREV[]_v_output=`AS_ECHO(["$ac_[]_AC_LANG_ABBREV[]_v_output"]) | sed 's/"-mGLOB[[^"]]*"/ /g'` ;;
 
   # Portland Group compiler has singly- or doubly-quoted -cmdline argument
   # Singly-quoted arguments were reported for versions 5.2-4 and 6.0-4.
   # Doubly-quoted arguments were reported for "PGF90/x86 Linux/x86 5.0-2".
   *-cmdline\ * | *-ignore\ * | *-def\ *)
-    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed "\
+    ac_[]_AC_LANG_ABBREV[]_v_output=`AS_ECHO([$ac_[]_AC_LANG_ABBREV[]_v_output]) | sed "\
        s/-cmdline  *'[[^']]*'/ /g; s/-cmdline  *\"[[^\"]]*\"/ /g
        s/-ignore  *'[[^']]*'/ /g; s/-ignore  *\"[[^\"]]*\"/ /g
        s/-def  *'[[^']]*'/ /g; s/-def  *\"[[^\"]]*\"/ /g"` ;;
 
   # If we are using fort77 (the f2c wrapper) then filter output and delete quotes.
   *fort77*f2c*gcc*)
-    ac_[]_AC_LANG_ABBREV[]_v_output=`echo "$ac_[]_AC_LANG_ABBREV[]_v_output" | sed -n '
+    ac_[]_AC_LANG_ABBREV[]_v_output=`AS_ECHO(["$ac_[]_AC_LANG_ABBREV[]_v_output"]) | sed -n '
         /:[[    ]]\+Running[[   ]]\{1,\}"gcc"/{
           /"-c"/d
           /[[.]]c"*/d
@@ -567,7 +567,7 @@ case $ac_[]_AC_LANG_ABBREV[]_v_output in
 
   # If we are using Cray Fortran then delete quotes.
   *cft90*)
-    ac_[]_AC_LANG_ABBREV[]_v_output=`echo $ac_[]_AC_LANG_ABBREV[]_v_output | sed 's/"//g'` ;;
+    ac_[]_AC_LANG_ABBREV[]_v_output=`AS_ECHO("$ac_[]_AC_LANG_ABBREV[]_v_output") | sed 's/"//g'` ;;
 esac
 
 ])# _AC_PROG_FC_V_OUTPUT
index 8f40fca3acdd8d6b6aabe3c73eac0beeb7d6247c..26cb0725d161e6f2a37e78904a025ddd67ca6733 100644 (file)
@@ -2049,7 +2049,7 @@ shift; shift
 # except with old shells:
 $1_os=$[*]
 IFS=$ac_save_IFS
-case $$1_os in *\ *) $1_os=`echo "$$1_os" | sed 's/ /-/g'`;; esac
+case $$1_os in *\ *) $1_os=`AS_ECHO(["$$1_os"]) | sed 's/ /-/g'`;; esac
 AC_SUBST([$1_os])dnl
 ])# _AC_CANONICAL_SPLIT
 
index cb53c31e7b940eb3db9aaeef054a1bdc56c16401..30a7d1faf2cd3a2da9a5695e2fdac42386cdabb0 100644 (file)
@@ -387,8 +387,8 @@ m4_ifdef([_AC_SUBST_FILES],
 [# Create commands to substitute file output variables.
 {
   echo 'cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1' &&
-  echo 'cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&' &&
-  echo "$ac_subst_files" | sed 's/.*/F@<:@"&"@:>@="$&"/' &&
+  AS_ECHO(['cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&']) &&
+  AS_ECHO(["$ac_subst_files"]) | sed 's/.*/F@<:@"&"@:>@="$&"/' &&
   echo "_ACAWK" &&
   echo "_ACEOF"
 } >conf$$files.sh &&
index b846d43250e55d6b0a0c546958fe84a167032263..6b4c3ae52d18147ec88bff2f580b7644d7422846 100644 (file)
@@ -519,7 +519,7 @@ do
        no | never | none) at_color=never ;;
        auto | tty | if-tty) at_color=auto ;;
        always | yes | force) at_color=always ;;
-       *) at_optname=`echo " $at_option" | sed 's/^ //; s/=.*//'`
+       *) at_optname=`AS_ECHO([" $at_option"]) | sed 's/^ //; s/=.*//'`
           AS_ERROR([unrecognized argument to $at_optname: $at_optarg]) ;;
        esac
        ;;
@@ -607,7 +607,7 @@ do
          at_jobs=`expr X$at_option : 'X-j\(.*\)'`
        fi
        case $at_jobs in *[[!0-9]]*)
-         at_optname=`echo " $at_option" | sed 's/^ //; s/[[0-9=]].*//'`
+         at_optname=`AS_ECHO([" $at_option"]) | sed 's/^ //; s/[[0-9=]].*//'`
          AS_ERROR([non-numeric argument to $at_optname: $at_jobs]) ;;
        esac
        ;;