From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5268 invoked by alias); 5 Dec 2010 17:43:51 -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: 28476 Received: (qmail 14421 invoked from network); 5 Dec 2010 17:43:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=BAYES_00,LONGWORDS, RCVD_IN_PSBL autolearn=no version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at ntlworld.com designates 81.103.221.56 as permitted sender) Date: Sun, 5 Dec 2010 17:25:15 +0000 From: Peter Stephenson To: zsh workers Subject: Re: extended braces syntax, {1..32..-03} Message-ID: <20101205172515.29a07db3@pws-pc.ntlworld.com> In-Reply-To: References: X-Mailer: Claws Mail 3.7.6 (GTK+ 2.22.0; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.1 cv=X0sWjjQ37bMP4yB/pNNinY3VxVB2n/hmdAjhihaCFGs= c=1 sm=0 a=YaBxVYOTs7YA:10 a=kj9zAlcOel0A:10 a=pGLkceISAAAA:8 a=NLZqzBF-AAAA:8 a=ImdcQd1-G54w14GonVYA:9 a=u8fXh0ZgFcH1LHAxxqv6agMcSSIA:4 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10 a=_dQi-Dcv4p4A:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 On Sun, 5 Dec 2010 16:41:20 +0100 Mikael Magnusson wrote: > This patch adds the syntax {start..end..step} to brace expansion. It > also allows negative numbers to be used (this was allowed when > braceccl was set before, which worked inconsistently). It also fixes > up zero-padding with negative numbers. You can specify zeropadding in > the step, as well as a negative step. >... > Missing still is documentation, but I've had this lying around since > august so I figured I'd post it and see if anyone wants to change > anything first. As long as we tests that pass, it's OK by me. Embarrassingly, there isn't a set of tests for brace expansion at the moment, though a few aspects are covered in other tests. Here is a short 'before' set of tests (I tried it out with the patch applied even though it doesn't test the new features). Index: Test/.distfiles =================================================================== RCS file: /cvsroot/zsh/zsh/Test/.distfiles,v retrieving revision 1.26 diff -p -u -r1.26 .distfiles --- Test/.distfiles 24 Apr 2009 09:11:59 -0000 1.26 +++ Test/.distfiles 5 Dec 2010 17:23:35 -0000 @@ -28,6 +28,7 @@ D05array.ztst D06subscript.ztst D07multibyte.ztst D08cmdsubst.ztst +D09brace.ztst E01options.ztst E02xtrace.ztst Makefile.in Index: Test/D09brace.ztst =================================================================== RCS file: Test/D09brace.ztst diff -N Test/D09brace.ztst --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Test/D09brace.ztst 5 Dec 2010 17:23:35 -0000 @@ -0,0 +1,52 @@ +# Tests for brace expansion + +%prep + + foo=(a b c) + arr=(foo bar baz) + +%test + + print X{1,2,{3..6},7,8}Y +0:Basic brace expansion +>X1Y X2Y X3Y X4Y X5Y X6Y X7Y X8Y + + print ${foo}{one,two,three}$arr +0:Brace expansion with arrays, no RC_EXPAND_PARAM +>a b conefoo ctwofoo cthreefoo bar baz + + print ${^foo}{one,two,three}$arr +0:Brace expansion with arrays, with RC_EXPAND_PARAM (1) +>aonefoo atwofoo athreefoo bonefoo btwofoo bthreefoo conefoo ctwofoo cthreefoo bar baz + + print ${foo}{one,two,three}$^arr +0:Brace expansion with arrays, with RC_EXPAND_PARAM (2) +>a b conefoo ctwofoo cthreefoo conebar ctwobar cthreebar conebaz ctwobaz cthreebaz + + print ${^foo}{one,two,three}$^arr +0:Brace expansion with arrays, with RC_EXPAND_PARAM (3) +>aonefoo atwofoo athreefoo aonebar atwobar athreebar aonebaz atwobaz athreebaz bonefoo btwofoo bthreefoo bonebar btwobar bthreebar bonebaz btwobaz bthreebaz conefoo ctwofoo cthreefoo conebar ctwobar cthreebar conebaz ctwobaz cthreebaz + + print X{01..4}Y +0:Numeric range expansion, padding (1) +>X01Y X02Y X03Y X04Y + + print X{1..04}Y +0:Numeric range expansion, padding (2) +>X01Y X02Y X03Y X04Y + + print X{7..12}Y +0:Numeric range expansion, padding (or not) (3) +>X7Y X8Y X9Y X10Y X11Y X12Y + + print X{07..12}Y +0:Numeric range expansion, padding (4) +>X07Y X08Y X09Y X10Y X11Y X12Y + + print X{7..012}Y +0:Numeric range expansion, pading (5) +>X007Y X008Y X009Y X010Y X011Y X012Y + + print X{4..1}Y +0:Numeric range expansion, decreasing +>X4Y X3Y X2Y X1Y -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/