[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature request: -0 option for tr
From: |
Eric Blake |
Subject: |
Re: feature request: -0 option for tr |
Date: |
Sat, 27 Jun 2009 21:26:17 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22) Gecko/20090605 Thunderbird/2.0.0.22 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Craig Sanders on 6/27/2009 7:20 PM:
> please add a -0 option to tr, which is equivalent to
> running:
>
> tr '\n' '\000'
Why should we burn an option letter, when it is not that much more typing
to get what you wanted anyways? An option letter makes the most sense
only when there is no other easy way to do the same task.
> this is a useful command for converting \n-terminated input lines to
> null-terminated strings suitable for feeding into 'xargs -0' as many
> programs can not generate null-terminated ouput by themselves.
This proposal doesn't really buy you anything. Either the output is
already nul-terminated (in which case you don't need an extra tr process
in the mix), or it is newline terminated (in which case you should just
use plain xargs instead of 'xargs -0', and you already have to worry about
the potential for filenames with embedded newlines). In short, throwing
tr in the mix just to convert newlines to nul bytes does not buy you any
security.
> it would also be useful if tr did this automatically if invoked
> as 'print0'.
GNU Coding Standards discourage programs that change their behavior based
on how argv[0] was spelled. But there is no need to change tr, when you
can easily do this yourself:
$ cat <<\EOF >>/usr/local/bin/print0
#!/bin/sh
exec tr '\n' '\0'
EOF
$ chmod +x /usr/local/bin/print0
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkpG4tgACgkQ84KuGfSFAYCqigCfe0uj9ulITy+i+kcVxwxah2f3
wUMAnRRvagxC43sko/y3Lo4izEMIYxdf
=BuUY
-----END PGP SIGNATURE-----