[CLUE-Tech] xargs
marcus hall
marcus at tuells.org
Sun Jan 5 20:31:30 MST 2003
On Sun, Jan 05, 2003 at 03:40:18PM -0700, Lynn Danielson wrote:
> On Sat, 2003-01-04 at 15:52, Jason S. Friedman wrote:
> > What's wrong with this:
> >
> > $ find . | xargs grep mystring
> > xargs: unmatched single quote
> >
> > For what it's worth, none of my files have a quote character in them.
>
> Are you certain? This is exactly the behavior that
> you'll get from xargs if you have an appostrophe in
> your file name.
While I won't argue that you won't get this behavior, I would argue
that you *shouldn't* get that behavior. IMHO, any xargs that attempts
to do shell-style expansion of the arguments is wrong. Now, the xargs
may not directly attempt it, because it may be passing the command to
system() instead of doing fork()/exec() itself, but that's hardly an
excuse for wrong behavior.
> David Willson asked a very similar question a while
> back, but I can't remember what other solutions were
> offered. You might want to google the archives.
Yes, I recall the issue, and thinking at the time that xargs was
broken. I don't dispute that some versions of xargs do that, but
I do assert that those that do are broken. In fact, xargs on RH8.0
(GNU xargs) *is* one of the broken xargs. To test, execute:
echo "it's a test" | xargs ls
You *should* get ls complaining about "it's" "a" and "test" not being
found (unless they actually do exist), but I get the same
"xargs: unmatched single quote" error message.
There's nothing really illegal about having a file name containing
shell meta-characters, and shell scripts are supposed to be able to
be written carefully enough to not mind it, but this behavior of xargs
breaks the "find ... | xargs" idiom and there's no way that I see to
get it to work if there are any files that contain meta-characters.
That's why I contend that it is wrong behavior.
marcus hall
marcus at tuells.org
More information about the clue-tech
mailing list