Follow own advice about \ in shell double-quoted strings

* 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.
This commit is contained in:
Paul Eggert 2024-08-04 16:55:05 -07:00
parent a12a3ec339
commit a245b8525a
3 changed files with 7 additions and 7 deletions

View 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

View 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

View 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)