]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Try 'print -r --' as a non-forking variant of 'printf %s\\n'.
authorEric Blake <ebb9@byu.net>
Mon, 10 Nov 2008 15:28:48 +0000 (08:28 -0700)
committerEric Blake <ebb9@byu.net>
Mon, 10 Nov 2008 16:06:39 +0000 (09:06 -0700)
* lib/m4sugar/m4sh.m4 (_AS_ECHO_PREPARE): Cater to Solaris ksh.
* doc/autoconf.texi (Limitations of Builtins) <printf>: Document
the print workaround.
Idea by Paolo Bonzini.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/autoconf.texi
lib/m4sugar/m4sh.m4

index 5ddd2f7785b28519eae1e4872333847b659c445b..6dd25c6f3e09b1310e7dba7ee0c1ebcf3ca76bdb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-11-10  Eric Blake  <ebb9@byu.net>
+
+       Try 'print -r --' as a non-forking variant of 'printf %s\\n'.
+       * lib/m4sugar/m4sh.m4 (_AS_ECHO_PREPARE): Cater to Solaris ksh.
+       * doc/autoconf.texi (Limitations of Builtins) <printf>: Document
+       the print workaround.
+       Idea by Paolo Bonzini.
+
 2008-11-10  Eric Blake  <ebb9@byu.net>
 
        Provide a section on all tools allowed in GNU Coding Standards.
index f59be60b74702337a8660e00692bea8257645fc7..86bed7f8d41a0ee22fbd3835f961d9a007be8af0 100644 (file)
@@ -15291,6 +15291,12 @@ example, @file{/usr/bin/printf} is buggy, so when using
 @command{/bin/sh} the command @samp{printf %010000x 123} normally dumps
 core.
 
+Since @command{printf} is not always a shell builtin, there is a
+potential speed penalty for using @code{printf %s\\n} as a replacement
+for an @command{echo} that does not interpret @samp{\} or leading
+@samp{-}. With Solaris @command{ksh}, it is possible to use @code{print
+-r --} for this role instead.
+
 
 @item @command{pwd}
 @c ----------------
index a506ef06dcb3747050eb9347d73c773f255eab7d..e0b7c55b824b485f4bb0e0fa127498966f778b42 100644 (file)
@@ -875,7 +875,7 @@ m4_defun_init([AS_ECHO_N],
 # _AS_ECHO_PREPARE
 # -----------------
 # Arrange for $as_echo 'FOO' to echo FOO without escape-interpretation;
-# and similarly for $as_echo_foo, which omits the trailing newline.
+# and similarly for $as_echo_n, which omits the trailing newline.
 # 'FOO' is an optional single argument; a missing FOO is treated as empty.
 m4_defun([_AS_ECHO_PREPARE],
 [[as_nl='
@@ -885,7 +885,13 @@ export as_nl
 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
   as_echo='printf %s\n'
   as_echo_n='printf %s'
 else