-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Bruno Haible on 6/22/2007 8:30 PM: > It is generally impossible to write reliable shell-scripts using 'echo', > when this 'echo' commands interprets backslahes. I'm not inclined to check > or rewrite the 500 echo commands in gnulib-tool. Instead, I'm applying this > workaround. Tested with bash, zsh, ksh, and /bin/sh of Linux, MacOS X, > AIX, HP-UX, IRIX, Solaris, OSF/1.
POSIX requires that echo interpret backslash sequences. Using echo with backslashes is flat out not portable, because of the argument over whether shells should comply to POSIX or continue to support current usage with \ uninterpreted. POSIX even admits this, and recommends the use of printf instead. > > libtool.m4 also tries other workarounds: searching for an 'echo' program > in $PATH:/usr/ucb (but how is this better than 'cat'?) or using a built-in > 'print -r' command (which shells except ksh have this?) or using 'printf' > (is that portable nowadays?). printf is not yet universally portable, but at least it is a shell builtin on many common shells (but notably not a builtin in Solaris' /bin/sh). Since forking external programs matters most on cygwin and mingw, where printf is always available as a builtin, it is one of the lightest-weight alternatives to echo when you are worried about the number of processes. > > > 2007-06-22 Bruno Haible <[EMAIL PROTECTED]> > > * gnulib-tool (echo): Ensure the echo primitive does not interpret > backslashes. > * tests/test-echo.sh: New file. While I admire your patch for trying to find reliable behavior, I have to question whether it right to demand non-POSIX behavior of all platforms. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGfJ9y84KuGfSFAYARAj+oAKC7iwKmiH7Nz+AvadD3QycnX4HwGACeKas4 lqPnELIxMnzrpp7NtlLkQCk= =XeDF -----END PGP SIGNATURE-----