News for hackers. Stuff that matters.
Re:Hints for writing Unix tools by fragmede on Monday October 20, 2014 @10:19PM (#8485623)
> newline-separated list of unescaped file names

That breaks when you have newlines in filenames, no?

Re:Hints for writing Unix tools by to3m on Tuesday October 21, 2014 @04:51AM (#8486490)
File names often have spaces in them, but very rarely newlines. Based on xargs's current behaviour, it's clearly no problem to just not support certain characters in file names by default. I just think it would have been more useful for it to not support a smaller set of names.
Re:Hints for writing Unix tools by mjevans on Tuesday October 21, 2014 @05:28AM (#8486597)
You would be amazed what various broken tools can produce for filenames.
Re:Hints for writing Unix tools by to3m on Tuesday October 21, 2014 @11:13AM (#8487734)
I can't decide if this is a rebuttal, or not ;) - assuming it is, note that the number of possible paths containing newlines OR spaces is smaller than the number of possible paths containing only newlines, so an xargs that didn't handle newlines by default would still be supporting more possible paths than it does in its current state!
Re:Hints for writing Unix tools by simpleigh on Tuesday October 21, 2014 @09:47AM (#8487271)
Only the other week I managed to mouse-twitch into existence a file that rm refused to remove.
Re:Hints for writing Unix tools by pstuart on Monday October 20, 2014 @10:43PM (#8485681)
> That breaks when you have newlines in filenames, no?

That seems like an extremely pathological case.

Re:Hints for writing Unix tools by userbinator on Monday October 20, 2014 @10:54PM (#8485711)
Pathological or not, ensuring that pathnames can essentially contain any byte value except the 0 terminator, and it will still work, is important to prevent surprising behaviour which often has security implications.
Re:Hints for writing Unix tools by typedweb on Tuesday October 21, 2014 @02:10PM (#8488804)
The only character not allowed in Unix file names is the forward slash directory separator, so even that would be a pathological mistake waiting to bite someone.

Edit: my mistake, they can't contain nulls either: https://news.ycombinator.com/item?id=8485861

Re:Hints for writing Unix tools by myhf on Monday October 20, 2014 @11:24PM (#8485768)
too pathological; didn't implement
Re:Hints for writing Unix tools by deathanatos on Monday October 20, 2014 @11:51PM (#8485827)
> That seems like an extremely pathological case.

When a human is creating files by hand, I almost certainly agree. When a program is creating files, however, it's only a matter of time before weird characters wind their way in there.

I really wish newlines had been disallowed. (There's UI implications, in addition to the parsing ones — how do you do a list view with newlines in the filename?; I also wish filenames had a reliable character set and weren't just bytes.)

Re:Hints for writing Unix tools by bmn_ on Tuesday October 21, 2014 @07:55AM (#8486880)
I think dwheeler is trying to get this fixed/standardised in POSIX via the Open group.
Re:Hints for writing Unix tools by oblio on Tuesday October 21, 2014 @10:57AM (#8487654)
That it's going to be an uphill battle is an understatement.

Someone replied on LWN, when he posted his proposal, that he had implemented a sort of home-grown database using non-UTF8 characters for the file names.

Rube Goldberg, indeed!

Re:Hints for writing Unix tools by userbinator on Tuesday October 21, 2014 @05:02PM (#8489983)
how do you do a list view with newlines in the filename?

Show them with the standard escape sequence for a newline:

    This\ filename\ncontains\ a\ newline
Same for any other characters that could be considered 'special' in output; I really wish the backslash convention for escaping was more common. Character sets and such are a UI/display issue, so I don't think there should be any special handling for them at the lower levels of the system.
Re:Hints for writing Unix tools by mjevans on Tuesday October 21, 2014 @05:30AM (#8486603)
UI issues; on display format all /printing display elements/ (including spaces as spaces and things that look like whitespace but aren't spaces) with readable glyphs, or those numeric standins for non-rendering glyphs.
[deleted]
Re:Hints for writing Unix tools by oneeyedpigeon on Tuesday October 21, 2014 @04:51AM (#8486488)
Whilst OSX's file-naming is disgusting (hello, /Library/WebServer/CGI-Executables), I don't think I've ever encountered newlines in filenames, and I've used it a fair amount. What are you referring to?
Re:Hints for writing Unix tools by mappu on Monday October 20, 2014 @11:58PM (#8485842)
And \x0 separator breaks when you have \x0 in filenames. Pragmatically it's a question of rarity, but ultimately the shell should support something like prepared queries in SQL.
Re:Hints for writing Unix tools by hedgehog on Tuesday October 21, 2014 @12:08AM (#8485861)