Paul Eggert wrote: > I think printf is portable nowadays, at least to the platforms that > gnulib-tool is likely to run on.
Indeed, 'printf' is useful to use when we find that it is a shell built-in, namely on bash >= 2.0. (See the patch in the other mail.) But other than that? 'printf' is portably available as a program. But if it's not a shell built-in, there is no point in using it since 'cat' is also available as a program, and is less likely to suffer size limitations. In particular, on AIX, HP-UX, IRIX, OSF/1, there is no other shell than the vendor's /bin/sh and /bin/ksh that one can use as a workaround, and these shells don't have 'printf' built-in. > One advantage of using printf is that it won't mishandle a string that > happens to equal "-n". This is a slight advantage over the BSD 'echo' command, but not over the echo emulated with 'cat'. > The substitute purposely does not treat "-n" specially; "-n" is just > another string, which is The Right Thing, usually. I agree. The overwhelming use of 'echo' is to output some string verbatim. Now that - as you say - 'printf' is universally available, the few cases where escape interpretation is desired or where end-of-line should be omitted can be done with 'printf'. It would be good if POSIX would standardize on such a simplified 'echo'. Bruno