Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Problems with zargs (Was: xargs should be a builtin)



2012-04-11 17:15:39 +0100, Peter Stephenson:
> On Wed, 11 Apr 2012 11:06:42 +0100
> Stephane Chazelas <stephane.chazelas@xxxxxxxxx> wrote:
> > By the way, there seems to be some issues with zargs:
> > 
> > ~$ zargs a b '' -- print -rl
> > a
> > b
> > ~$ zargs a -- print -rl ''
> > a
> > ~$ zargs -e a '' print -rl
> > a print -rl
> > ~$ zargs --eof= a '' print -rl
> > a
> 
> It helps if everyone always says explicitly what the problem actually
> is, it saves lots of guesswork.

Sorry about that. Wrote in a rush.

> I've come up with the following for the problems I understand, but I'm
> sure it could do with a bit more prodding.
[...]

Thanks. That seems to do the trick.

May I knitpick:

~$ ''() echo X "$@"
~$ zargs 1 2 -- ''
1 2
~$ zargs 1 2 -- '' ''
X  1 2

--- zargs.old   2012-04-12 10:26:20.658633028 +0100
+++ /usr/share/zsh/functions/Misc/zargs 2012-04-12 10:27:20.709077765 +0100
@@ -174,7 +174,7 @@
 else set -- "${(@)argv[1,end-1]}"
 fi

-if [[ -n $command ]]
+if (($#command))
 then (( c = $#command - 1 ))
 else command=( print -r -- )
 fi


-- 
Stephane



Messages sorted by: Reverse Date, Date, Thread, Author