NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Monday June 08, 2009
04:30 AM
POSIX and xargs
Dear POSIX,
Why did you decide that xargs with no filename arguments should run the command once? I can only assume that there are zero mathematicians and zero computer scientists on the relevant committee. How else could such a demented special case get through?
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Either Way Can Be Wrong (Score:1)
I used to think that as well (though I'm not sure Posix are necessarily at fault: possibly they just codified what was already a de facto standard).
Then I encountered a situation where I did need the command to run once, even with no arguments. In normal circumstances* the command runs exactly once regardless of the number of arguments, not once per argument, so there's consistency in making this always be once, even with no arguments.
Whichever way they picked was going to be wrong sometimes. What they re
There is worse precedent (Score:1)
Most shells will invoke
fooand pass a literalbar.*as the first argument if you runfoo bar.*if nothing in the current directory matchesbar.*. In bash since 2.something you canshopt -s failglobto prevent this.But then the shell will also refuse to let you run
foo bar.* baz.*if eitherbar.*orbaz.*fail, when really you probably only wanted it to refuse if both fail. So basically you want the behaviour ofshopt -s nullglobwhen there’s more than one glob.Or at least, you want that behaviour mos
A LiveJournal reply (Score:2)
There's another reply to this journal entry over here [livejournal.com].
--
Esli epei eto cumprenan, shris soa Sfaha.
Aettot ibrec epesecoth, spakhea scrifeteis.