From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29777 invoked by alias); 13 Apr 2012 07:25:11 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30393 Received: (qmail 2588 invoked from network); 13 Apr 2012 07:25:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120412160510.ZM1863@torch.brasslantern.com> Date: Thu, 12 Apr 2012 16:05:10 -0700 In-reply-to: <20120411100642.GA8180@chaz.gmail.com> Comments: In reply to Stephane Chazelas "Problems with zargs (Was: xargs should be a builtin)" (Apr 11, 11:06am) References: <0363642A-FD71-4DEE-8284-D7E72EAC8AD0@Yost.com> <87k41mr9u7.fsf@ft.bewatermyfriend.org> <20120411100642.GA8180@chaz.gmail.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "zsh-workers@zsh.org" Subject: Re: Problems with zargs (Was: xargs should be a builtin) MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Apr 11, 11:06am, Stephane Chazelas wrote: } } By the way, there seems to be some issues with zargs: } } ~$ zargs a b '' -- print -rl } a } b } ~$ zargs a -- print -rl '' } a Hmm, empty strings are being collapsed out of $argv[end+1,-1] when it is assigned. I'm not remembering whether that's expected or something new. Patch below, though it probably needs some more test cases. } ~$ zargs -e a '' print -rl } a print -rl } ~$ zargs --eof= a '' print -rl } a This is actually the expected behavior. "zargs --help": --eof[=eof-str], -e[eof-str] Change the end-of-input-args string from "--" to eof-str. If given as --eof=, an empty argument is the end; as --eof or -e, with no (or an empty) eof-str, all arguments are input-args. Index: Functions/Misc/zargs =================================================================== retrieving revision 1.6 diff -c -r1.6 zargs --- zargs 20 Dec 2011 17:13:38 -0000 1.6 +++ zargs 12 Apr 2012 22:48:19 -0000 @@ -167,11 +167,11 @@ elif (( $#eof )); then end=$argv[(i)${eof##-(e|-eof=)}] else end=$argv[(i)--] fi -local -a args call command; command=( ${argv[end+1,-1]} ) +local -a args call command; command=( "${(@)argv[end+1,-1]}" ) if (( $opts[(I)-(null|0)] )) -then set -- ${(ps:\000:)argv[1,end-1]} -else set -- $argv[1,end-1] +then set -- "${(@ps:\000:)argv[1,end-1]}" +else set -- "${(@)argv[1,end-1]}" fi if [[ -n $command ]] @@ -187,7 +187,7 @@ then print -u2 -r -- "$call" fi eval "{ - \$call + ${(@qq)call} } $bg"' local ret=0 analyze=' case $? in @@ -205,7 +205,7 @@ if (( $opts[(I)-(-no-run-if-empty|r)] )) then return 0 else - call=($command) + call=( "${(@)command}" ) # Use "repeat" here so "continue" won't complain. repeat 1; do eval "$execute ; $analyze"; done return $ret @@ -275,11 +275,11 @@ ((ARGC)) || break for (( end=l; end && ${(c)#argv[1,end]} > s; end/=2 )) { } (( end > n && ( end = n ) )) - args=( $argv[1,end] ) + args=( "${(@)argv[1,end]}" ) shift $((end > ARGC ? ARGC : end)) if (( $#i )) - then call=( ${command/$i/$args} ) - else call=( $command $args ) + then call=( "${(@)command/$i/$args}" ) + else call=( "${(@)command}" "${(@)args}" ) fi if (( ${(c)#call} > s )) then