On 2005-04-16 "Linda A. W." <[EMAIL PROTECTED]> wrote: > It would be nice if xargs had an option to enclose the arguments it reads > in in either double or single quotes before passing them to a program.
> This would be especially useful for files with "spaces" in them. > :-) [...] Actually it would not. ;-) For dealing with filenames with spaces you need quotes to keep the shell from splitting the input and passing the name as a single argument to the program. e.g. for /tmp$ /bin/ls "with space" the shell invokes /bin/ls with the single argument »with space« (without the quotes!), while for /tmp$ /bin/ls with space the shell would split at the space and invoke /bin/ls with the two arguments »with« and »space«. However when xargs _invokes_ programs there is no shell involved echo foo | xargs ls causes ls to be run with arguments foo, if xargs added quotes this fail horribly, as there is no file named "foo" (with quotes). It is the other way round, you have to keep _xargs_ from splitting _its_ _own_ input: /tmp$ echo 'with space' | xargs ls ls: with: No such file or directory ls: space: No such file or directory if you manage that xargs does not need to add quotes, as it does not invoke a shell: -------- /tmp$ echo "'with space'" | xargs ls with space -------- So you actually do not need to adapt xargs, but the program that generates the input for xargs. Usually that is find, and find -some -criteria -print0 | xargs -r0 some_program works wonderfully with as insane filenames as you can imagine. cu andreas -- "See, I told you they'd listen to Reason," [SPOILER] Svfurlr fnlf, fuhggvat qbja gur juveyvat tha. Neal Stephenson in "Snow Crash" http://downhill.aus.cc/ _______________________________________________ Bug-findutils mailing list Bug-findutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-findutils