On Sun, 12 Aug 2012 14:41:42 -0600 (MDT), Jon Trulson wrote: > On Sun, 12 Aug 2012, Douglas Mencken wrote: > > >> I am pretty sure that 'echo -n' and 'echo -e' work everywhere. Why > >> not use those instead? > > > > printf is available everywhere; "echo -n" is an exotic, "echo -e" is > > much more exotic > > > > No, I have yet to see a system where echo -n/-e was not supported, > even on ancient systems. > > I had thought printf was a bash addition. ksh supports print, but > even there -n/-e for echo works..
printf is POSIX. Whether that's a separate utility or a shell built-in is left up to the implementation. echo is impossible to be used portably, as stated in the "APPLICATION USAGE" section on echo. Therefore, POSIX recommends always using printf(1). Also, from RATIONALE: As specified, echo writes its arguments in the simplest of ways. The two different historical versions of echo vary in fatally incompatible ways. The BSD echo checks the first argument for the string -n which causes it to suppress the <newline> that would otherwise follow the final argument in the output. The System V echo does not support any options, but allows escape sequences within its operands, as described for XSI implementations in the OPERANDS section. And in fact, this situation is even worse due to the fact that echo too can be implemented as a shell built-in, often with different options than the stand-alone command. For instance, on OpenBSD: 23:01 ~ $ echo -e foo foo 23:01 ~ $ /bin/echo -e foo -e foo 23:01 ~ $ ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ cdesktopenv-devel mailing list cdesktopenv-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel