Zsh Mailing List Archive
Messages sorted by:
Re: zargs doesn't work reliably
- X-seq: zsh-workers 22617
- From: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- To: zsh-workers <zsh-workers@xxxxxxxxxx>
- Subject: Re: zargs doesn't work reliably
- Date: Fri, 18 Aug 2006 05:16:50 +0200
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ugf3Kj/Lz5vCx+WpuDusCHNjvWa4NDt97PUdsY3fCI5kMzZAcJWhUOzFl8KiE/Nn0eJGlexQWabkFYfjKwBaGwi2gR0hnNjWBmSlG5hL4lWV5GA92MCzRUaP6MremIObuAHL4CUGvsKl0aWd4vad7bKMlzGocY2YdFB6yaBVQAE=
- In-reply-to: <060817194225.ZM23196@xxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <237967ef0608171559k1bd8053bxf7a3d1cb53ef33e7@xxxxxxxxxxxxxx> <060817194225.ZM23196@xxxxxxxxxxxxxxxxxxxxxx>
On 8/18/06, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Aug 17, 3:59pm, Mikael Magnusson wrote:
} Usage: zargs [options --] [input-args] [-- command [initial-args]]
} % touch -- -- -+
There are approximately eleventeen zillion unix/linux commands that
break given those file names, including rm, ls, and cp, so I'm not
going to get particularly worked up about zargs behaving similarly.
% ls -l -- *
-rw-r--r-- 1 mikaelh users 0 2006-08-18 00:55 -+
-rw-r--r-- 1 mikaelh users 0 2006-08-18 00:55 --
However, if you'd looked just a little further, you'd find that in
fact zargs already has a solution for this problem. There is even
an example in the manual:
In the event that the string `--' is or may be an INPUT, the -e
option may be used to change the end-of-inputs marker. Note that
this does _not_ change the end-of-options marker. For example, to
use `..' as the marker:
zargs -e.. -- **/*(.) .. ls -l
This is a good choice in that example because no plain file can be
named `..', but the best end-marker depends on the circumstances.
(End manual page example, begin new one.) You can even do:
zargs -e$'\0' -- * $'\0' ls -d
unless you somehow have a file named (the nul byte).
} since input-args is the only part you do not control
The only part who does not control?
What i meant was it's the only part of the command that may contain
unplanned -- instances. Unless you also glob somewhere else in the
command... but that seems like a bad idea?
} it should come last, like so
} Usage: zargs [options --] [command [initial-args]] -- [input-args]
I think the designers of the xargs command, after which zargs is closely
modeled, would disagree with you. See "man xargs".
} A problem is how to give -- as initial-args then
Would this be possible?
zargs '[options]' 'command [initial-args]' [input-args]
ie the ' are literal quotes in the command so zargs knows exactly what
to do with the first two arguments (in which case you'd have to zargs
'' '' * if you wanted to omit them so maybe not aesthetically pleasing
in that regard).
Precisely. Another problem is that the command and initial-args may be
omitted, but the input-args may not be.
Sorry, I should have looked in the manual. In my defense zargs --help
was so helpful that i didn't suspect it left anything useful out and i
did say i was tired :). Thanks for the pointers.
Messages sorted by: