On 01-Nov-2007, at 18:03, Michael G Schwern wrote:
        $ find . -print0 -name '*.txt' | xargs -0 rm

That's a mistake.

Whoopsie, everything's deleted. 10 gigs of fine public educational video, gone. Turns out putting -print0 first instead of last causes some sort of crazy find switch boolean madness to short circuit and everything becomes true.

Nope, the result of the expression is exactly the same as before.

Consider the difference between "find ... -print -exec something '{}' ';'" and "find ... -exec something '{}' ';' -print".

The former prints out all the files it's applying "something" to, so you know what you somethinged.

The latter prints out all the files for which "something" succeeded, so you know what the something files are.

There's nothing crazy about it at all. It's not a flag, if it was a flag it would be a single character (this is a good decade and a hlaf before that crazy GNU getopt shit). It's a term in an expression. The hateful thing isn't that it behaved that way, it's that they put a "-" in front of the terms in the expression instead of something else like "+" or "=" so you wouln't think it was some kind of long format option. They should have been able to see 15 years into the future and realize that when people started using versions of getopt (something else that didn't exist when find was written) that supported long options that people would decide that find was just doing the same thing.

And then they should have realised that those crazy GNU guys would make the final "-print" optional, so it looked even more like a flag. Because it's not.

And I'm really not sure whether I'm being sarcastic there or not. The "-" business was asking for trouble, and there's always been some people complaining about find being some kind of exception because it uses those crazy long options. It's not, it's consistent, it's just hateful.

But it took the Free Software Foundation to pump the hate up to 11, and I can't blame them for not realizing they were going to.

(That kind of thing is why I used "+" to indicate long options when I was playing around with the things, so they didn't get confused with short ones)



Reply via email to