[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xargs feature request...

From: James Youngman
Subject: Re: xargs feature request...
Date: Sat, 16 Apr 2005 09:18:15 +0100
User-agent: Mutt/1.3.28i

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]