]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Avoid AIX 6.1 ksh88 ECHO_C command substitution bug.
authorJan Madzik <jmadzik@gmail.com>
Tue, 30 Jun 2009 06:06:24 +0000 (08:06 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 30 Jun 2009 18:48:59 +0000 (20:48 +0200)
* lib/m4sugar/m4sh.m4 (_AS_ECHO_N_PREPARE): Ensure more than
one character is output with `\c'; reset echo output state
if buggy ksh was detected, and set ECHO_T instead of ECHO_C.
* doc/autoconf.texi (Limitations of Builtins): Document it.
* tests/m4sh.at (ECHO_C): New test.
* THANKS: Update.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
THANKS
doc/autoconf.texi
lib/m4sugar/m4sh.m4
tests/m4sh.at

index 5f89c1b24bc2b67496d247601c100d574d7cb19b..8f0b5ae0b9b5910816d3ad52f9545d3508551c03 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-06-30  Jan Madzik  <jmadzik@gmail.com>  (tiny change)
+           Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Avoid AIX 6.1 ksh88 ECHO_C command substitution bug.
+       * lib/m4sugar/m4sh.m4 (_AS_ECHO_N_PREPARE): Ensure more than
+       one character is output with `\c'; reset echo output state
+       if buggy ksh was detected, and set ECHO_T instead of ECHO_C.
+       * doc/autoconf.texi (Limitations of Builtins): Document it.
+       * tests/m4sh.at (ECHO_C): New test.
+       * THANKS: Update.
+
 2009-06-27  William Pursell  <bill.pursell@gmail.com>  (tiny change)
 
        Fix grammaro in documenation.
diff --git a/THANKS b/THANKS
index eab63f2c551bd381da3d8a051367271334f09711..30f1b2d35db9c95521a2df5e8d32ccfb6c625d08 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -160,6 +160,7 @@ Iohannes m zmoelnig         zmoelnig@iem.at
 J C Fitzgerald              v7022@wave.co.nz
 Jaap Haitsma                jaap@haitsma.org
 James A. Lupo               lupoja@feynman.ml.wpafb.af.mil
+Jan Madzik                  jmadzik@gmail.com
 Jason Molenda               jsm@cygnus.com
 Jeff Garzik                 jgarzik@pobox.com
 Jeff Painter                ?
index 455d1c4151ac6b69bca5dff848a44d9e836695c6..5908bbb50780b43bbfcfc2e6800ee948ed63a490 100644 (file)
@@ -15733,7 +15733,10 @@ their handling.  For @samp{echo '\n' | wc -l}, the @command{sh} of
 Solaris outputs 2, but Bash and Zsh (in @command{sh} emulation mode) output 1.
 The problem is truly @command{echo}: all the shells
 understand @samp{'\n'} as the string composed of a backslash and an
-@samp{n}.
+@samp{n}.  Within a command substitution, @samp{echo 'string\c'} will
+mess up the internal state of ksh88 on AIX 6.1 so that it will print
+the first character @samp{s} only, followed by a newline, and then
+entirely drop the output of the next echo in a command substitution.
 
 Because of these problems, do not pass a string containing arbitrary
 characters to @command{echo}.  For example, @samp{echo "$foo"} is safe
index c7b0bffc239500d1fbe9fae4d31a21d8ca7ec49f..b2cabd7924cedd80bcc869a39b0d31a901ddd017 100644 (file)
@@ -780,14 +780,19 @@ m4_defun_init([_AS_ECHO_LOG],
 # display the checking message.  In addition, caching something used once
 # has little interest.
 # Idea borrowed from dist 3.0.  Use `*c*,', not `*c,' because if `\c'
-# failed there is also a newline to match.
+# failed there is also a newline to match.  Use `xy' because `\c' echoed
+# in a command substitution prints only the first character of the output
+# with ksh version M-11/16/88f on AIX 6.1; it needs to be reset by another
+# backquoted echo.
 m4_defun([_AS_ECHO_N_PREPARE],
 [ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in @%:@((((
+case `echo -n x` in @%:@(((((
 -n*)
-  case `echo 'x\c'` in
+  case `echo 'xy\c'` in
   *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
-  *)   ECHO_C='\c';;
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
   esac;;
 *)
   ECHO_N='-n';;
index 065a9dda8676c17a9320291144524ff016c0ee6b..f936a7cd59b1b264d06f9aa3665fb2c79899da1a 100644 (file)
@@ -1412,3 +1412,23 @@ AT_CHECK_M4SH
 AT_CHECK([./script])
 
 AT_CLEANUP
+
+
+## -------- ##
+## ECHO_C.  ##
+## -------- ##
+
+AT_SETUP([ECHO_C])
+
+AT_DATA_M4SH([script.as], [[dnl
+AS_INIT
+_AS_PREPARE
+foo=`echo foobar`
+echo "$foo"
+]])
+
+AT_CHECK_M4SH
+AT_CHECK([./script], [], [foobar
+])
+
+AT_CLEANUP