On Tue, Jun 04, 2013 at 10:45:38PM +1000, Matthew Cengia wrote:
> Using tr to convert newlines to \0 for parsing with xargs -0 is no
> better than using xargs without -0. How does tr know whether a newline
> is part of the filename, or a delimiter between filenames? Only the
> program generating the file list could know that.

tr doesn't and can't. 

it's still a LOT better (than xargs' default of white-space as a
delimter) because even though \n is a valid character in a filename,
only the most pathologically stupid people or broken software or the
most unlikely of contrived cases would actually use one. you just
shouldn't do some things even though it's technically permitted.

it's also no different to using -d '\n' with a modern xargs. in both
cases, you're making the assumption that only an idiot would use
a newline in a filename so it's safe to rely on it as a filename
delimiter. some assumptions are reasonable to make.

spaces in filenames, OTOH, are quite common. especially if you have to
deal with files uploaded by Mac or Windows users. using -d '\n' or
converting newlines to NULs for use with -0 are both conviently useful
in such cases...with the proviso, of course, that you understand that
pathologically stupid and unlikely filenames with newlines in them can
still be a problem.

in the case of debian package listings, the format IS newline separated,
with one filename per line - an extremely common format on *nix systems
for filenames and many other text lists.

craig

-- 
craig sanders <[email protected]>

BOFH excuse #289:

Interference between the keyboard and the chair.
_______________________________________________
luv-main mailing list
[email protected]
http://lists.luv.asn.au/listinfo/luv-main

Reply via email to