Dasn wrote:
> On 05/01/08 14:06 +0100, Bram Moolenaar wrote: > > > >An alternative would be to try using NUL characters to separate the > >items. Unfortunately I could not find a way to make this work for the > >sh of FreeBSD that I'm using. The builtin echo command accepts -n and > >-e, but not at the same time. That's weird, but that's how it is. So > >you could use -e to add a NUL character, but you also get a NL then. > > > > Oh, yes, 'echo' is not portable. The printf(1) should be used for this > case. As stated in the SUSV: > > http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html > > > APPLICATION USAGE > > > > It is not possible to use echo portably across all POSIX systems > > unless both -n (as the first argument) and escape sequences are > > omitted. > > > > The printf utility can be used portably to emulate any of the > > traditional behaviors of the echo utility ... > > > # tested in FreeBSD, OpenBSD and a Linux > $ for i in * ; do env printf "%s\0" $i; done We haven't been using printf so far, thus this needs to be tested to find any system where it doesn't work. The opengroup isn't always right (I don't think they cover Cygwin). "echo" is a builtin, "printf" is a program. I think this means it will be a bit slower, right? Not sure if this matters. Also, since printf is a program, isn't there a risk that with some weird arguments something strange may go wrong? Why do you put "env" before "printf"? -- With sufficient thrust, pigs fly just fine. -- RFC 1925 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
