On Fri, Apr 15, 2005 at 03:17:06PM -0700, Linda A. W. 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. > :-)
The program run by xargs is invoked directly with execvp(), and so the arguments are not processed by the shell at all. This means that spaces and other special characters in the file names (if they are file names) are not treated specially at all. For this reason it shouldn't be neccessary to use quotes. The only time things don't work out quite this way is when the program you are invoking is itself a shell script. In this situation the arguments will be correctly passed to the shell script but the script may not be processing such arguments directly. Within the script, spaces within the filenames are protected by correct quoting, for example "$@". The xargs program also, by default, separates its arguments with spaces. When it is operating in this mode, it does interpret quotes as I think you are hoping. However, if you need to process arguments which contain spaces and newlines, it is best to use xargs' "-0" option, which corresponds to find's "-print0" action. Regards, James. _______________________________________________ Bug-findutils mailing list Bug-findutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-findutils