]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Follow own advice about \ in shell double-quoted strings
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 4 Aug 2024 23:55:05 +0000 (16:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 7 Aug 2024 00:59:36 +0000 (17:59 -0700)
* lib/autoconf/headers.m4 (_AC_HEADERS_EXPANSION):
* lib/m4sugar/m4sh.m4 (AS_ECHO):
Go back to using '%s\n' instead of "%s\n".
(AS_VAR_GET): Work around the quoting problem by using printf
directly with "%s\\n" instead of AS_ECHO; this is safe now that we
assume printf.

doc/autoconf.texi
lib/autoconf/headers.m4
lib/m4sugar/m4sh.m4

index 4d809153f9604f6bfef8708b04b098bb7644285b..cc588f4993c346b91c61e87c048d0b1b5216e9e0 100644 (file)
@@ -18080,7 +18080,7 @@ only if you know that @var{foo}'s value cannot contain backslashes and
 cannot start with @samp{-}.
 
 Normally, @command{printf} is safer and easier to use than @command{echo}
-and @command{echo -n}.  Thus, you should use @command{printf "%s\n"}
+and @command{echo -n}.  Thus, you should use @command{printf '%s\n'}
 instead of @command{echo}, and similarly use @command{printf %s} instead
 of @command{echo -n}.
 
@@ -19392,11 +19392,11 @@ The empty alternative is not portable.  Use @samp{?} instead.  For
 instance with Digital Unix v5.0:
 
 @example
-> printf "foo\n|foo\n" | $EGREP '^(|foo|bar)$'
+> printf 'foo\n|foo\n' | $EGREP '^(|foo|bar)$'
 |foo
-> printf "bar\nbar|\n" | $EGREP '^(foo|bar|)$'
+> printf 'bar\nbar|\n' | $EGREP '^(foo|bar|)$'
 bar|
-> printf "foo\nfoo|\n|bar\nbar\n" | $EGREP '^(foo||bar)$'
+> printf 'foo\nfoo|\n|bar\nbar\n' | $EGREP '^(foo||bar)$'
 foo
 |bar
 @end example
index dec8538b3dfd9edcc1c984226a023805af56d1fa..6f2a7b093cc24fb3846bc4a6b4afdf6fc6072044 100644 (file)
@@ -264,7 +264,7 @@ do
     _AC_CHECK_HEADER_COMPILE_FN()ac_fn_$1_check_header_compile "$LINENO" ]dnl
 [$ac_header ac_cv_header_$ac_cache "$ac_includes_default"
     if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then
-      printf "%s\n" "[#]define $ac_item 1" >> confdefs.h
+      printf '%s\n' "[#]define $ac_item 1" >> confdefs.h
     fi
     ac_header= ac_cache=
   elif test $ac_header; then
index c973f17788205eb63be03a90ca0828742a33fba7..a4f0f699931795023273ddfdb43ffa563e24c4ab 100644 (file)
@@ -1113,7 +1113,7 @@ m4_define([AS_ECHO],
 dnl Extra quoting in case 's' or 'n' are user-defined macros when this
 dnl is expanded; they almost certainly aren't meant to be used here.
 dnl See bug 110377.
-[printf "[%s\n]" $1])
+[printf '[%s\n]' $1])
 
 
 # AS_ECHO_N(WORD)
@@ -2051,7 +2051,7 @@ m4_define([AS_VAR_COPY],
 m4_define([AS_VAR_GET],
 [AS_LITERAL_WORD_IF([$1],
               [$$1],
-  [`eval 'as_val=${'_AS_ESCAPE([[$1]], [`], [\])'};AS_ECHO(["$as_val"])'`])])
+  [`eval 'as_val=${'_AS_ESCAPE([[$1]], [`], [\])'};printf "[%s\\n]" "$as_val"'`])])
 
 
 # AS_VAR_IF(VARIABLE, VALUE, IF-TRUE, IF-FALSE)