From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15995 invoked by alias); 30 Oct 2012 07:05:56 -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: 30768 Received: (qmail 8287 invoked from network); 30 Oct 2012 07:05:44 -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=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at dima.secretsauce.net does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:subject:message-id :in-reply-to:references:mime-version:content-type; s=smtpout; bh=Qe1q2U2duqT4e6vOxDRoOZwo8+Y=; b=fzgWI0suvSFhBD7pmA0Jgp9/5ZTc 57scq7ivuo3MaG6NvEdrHRVevKy4GAIjS080y83e2/53WO0TbMq30nB/L0ojQNoN E7efiSnzhaoensGyTWJC4Ks0cNaA9sgPE8yMzj2h43OgpDvWJl+5SHaKskcGiohl xe55i6KUkU1vj8Q= X-Sasl-enc: bB4ya0WLkRCFwWNuxyOonV5hxn9m8opX1LatwQkRC28D 1351580738 Date: Tue, 30 Oct 2012 00:05:36 -0700 From: Dima Kogan To: zsh-workers@zsh.org Subject: Re: Possible bug in zargs Message-ID: <20121030000536.260d4c15@shorty.local> In-Reply-To: <20121027153400.77571174@shorty.local> References: <20121027153400.77571174@shorty.local> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/0=rvzFxLjxOA1t4_CUr9xr4" --MP_/0=rvzFxLjxOA1t4_CUr9xr4 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline > On Sat, 27 Oct 2012 15:34:00 -0700 > Dima Kogan wrote: > > I can't seem to get the -n option in zargs to work right. This looks like a bug > to me, but maybe I'm not using it correctly: > > dima@shorty:/tmp$ ls -l > total 12 > -rw-r--r-- 1 dima dima 1 Oct 27 15:29 1 > -rw-r--r-- 1 dima dima 5 Oct 27 15:29 2 > -rw-r--r-- 1 dima dima 5 Oct 27 15:29 3 > > > dima@shorty:/tmp$ zargs -- * -- ls -l > -rw-r--r-- 1 dima dima 1 Oct 27 15:29 1 > -rw-r--r-- 1 dima dima 5 Oct 27 15:29 2 > -rw-r--r-- 1 dima dima 5 Oct 27 15:29 3 > > dima@shorty:/tmp$ zargs -- * -- ls > 1 2 3 > > dima@shorty:/tmp$ zargs -n1 -- * -- ls > 1 > 2 > 3 > > dima@shorty:/tmp$ zargs -n1 -- * -- ls -l > zargs: argument list too long Attached is a patch that fixes this. There was some misbehaving logic in the script. I don't understand why that logic was ever necessary. Does anybody know why the value of $n was connected to the value of $c at all? --MP_/0=rvzFxLjxOA1t4_CUr9xr4 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-n-option-of-zargs-now-works-correctly.patch >>From b2d0722f78ce1c8effd69119b989a9112cbf5d27 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Tue, 30 Oct 2012 00:02:45 -0700 Subject: [PATCH] -n option of zargs now works correctly Before this patch, the following wouls happen: dima@shorty:/tmp$ ls 1 2 3 dima@shorty:/tmp$ zargs -n1 -- * -- ls -l zargs: argument list too long --- Functions/Misc/zargs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Functions/Misc/zargs b/Functions/Misc/zargs index 71fd428..59b369e 100644 --- a/Functions/Misc/zargs +++ b/Functions/Misc/zargs @@ -212,20 +212,13 @@ then fi fi -n=${${n##-(n|-max-args(=|))}:-$[ARGC+c]} +n=${${n##-(n|-max-args(=|))}:-$[ARGC]} if (( n <= 0 )) then print -u2 'zargs: value for max-args must be >= 1' return 1 fi -if (( n > c )) -then (( n -= c )) -else - print -u2 zargs: argument list too long - return 1 -fi - s=${${s##-(s|-max-chars(=|))}:-20480} if (( s <= 0 )) then -- 1.7.10.4 --MP_/0=rvzFxLjxOA1t4_CUr9xr4--