From 6fb99317ff71482eac591c098f72cf27f134839f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 7 Feb 2007 17:45:37 +0000 Subject: [PATCH] * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Prefer \r to an actual carriage return. Use "ac_cr" to contain the actual carriage return. * doc/autoconf.texi (Limitations of Usual Tools): Document problem with traditional Awk and begin. * tests/torture.at (Limitations of Builtins): Document the problem with Bash 2.03 printf. (Substitute and define special characters): Remove trailing white space. Work around a bug in Solaris 8 /bin/bash. --- ChangeLog | 12 ++++++++++++ doc/autoconf.texi | 22 ++++++++++++++++++++-- lib/autoconf/status.m4 | 13 +++++++++---- tests/torture.at | 10 +++++----- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 820476b1..5eb9ecfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-02-07 Paul Eggert + + * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Prefer \r to + an actual carriage return. Use "ac_cr" to contain the actual + carriage return. + * doc/autoconf.texi (Limitations of Usual Tools): Document problem + with traditional Awk and begin. + * tests/torture.at (Limitations of Builtins): Document the problem + with Bash 2.03 printf. + (Substitute and define special characters): + Remove trailing white space. Work around a bug in Solaris 8 /bin/bash. + 2007-02-06 Ralf Menzel (tiny change) * lib/autoconf/status.m4 (_AC_OUTPUT_FILES_PREPARE): Redirect diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 310b9f2d..7e47ee7b 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -12636,16 +12636,23 @@ fi @c ------------------ @prindex @command{printf} A format string starting with a @samp{-} can cause problems. -Bash (e.g., 2.05b) interprets it as an options argument and +Bash interprets it as an option and gives an error. And @samp{--} to mark the end of options is not good in the Net@acronym{BSD} Almquist shell (e.g., 0.4.6) which takes that literally as the format string. Putting the @samp{-} in a @samp{%c} -or @samp{%s} is probably the easiest way to avoid doubt, +or @samp{%s} is probably easiest: @example printf %s -foo @end example +Bash 2.03 mishandles an escape sequence that happens to evaluate to @samp{%}: + +@example +$ @kbd{printf '\045'} +bash: printf: `%': missing format character +@end example + @item @command{read} @c ------------------ @@ -13009,6 +13016,17 @@ $ @kbd{gawk 'function die () @{ print "Aaaaarg!" @} Aaaaarg! @end example +Posix says that if a program contains only @samp{BEGIN} actions, and +contains no instances of @code{getline}, then the program merely +executes the actions without reading input. However, traditional Awk +implementations (such as Solaris 10 @command{awk}) read and discard +input in this case. Portable scripts can redirect input from +@file{/dev/null} to work around the problem. For example: + +@example +awk 'BEGIN @{print "hello world"@}' /dev/null /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi dnl dnl Define the pipe that does the substitution. m4_ifdef([_AC_SUBST_FILES], @@ -524,7 +529,7 @@ cat >>"\$tmp/subs1.awk" < "\$tmp/subs.awk" +sed 's/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g' < "\$tmp/subs1.awk" > "\$tmp/subs.awk" _ACEOF ]dnl end of double-quoted part diff --git a/tests/torture.at b/tests/torture.at index 8674d1c1..8a714a0e 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -1,8 +1,8 @@ # -*- Autotest -*- -# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software -# Foundation, Inc. -# +# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free +# Software Foundation, Inc. + # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) @@ -623,7 +623,7 @@ abc@bar @baz@baz abc@bar @baz@baz@ abc@bar @baz@@baz@ @file@ - @file@ + @file@ X@file@ @file@X ]) @@ -644,7 +644,7 @@ baz=bla for k in 0 1 2 3 4 5 6 7; do case $i$j$k in #( 000) ;; #( - *) printf \\$i$j$k ;; + *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug. esac done done -- 2.11.4.GIT