From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27017 invoked by alias); 8 Mar 2015 23:49:30 -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: 34684 Received: (qmail 23141 invoked from network); 8 Mar 2015 23:49:28 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.2 Date: Mon, 9 Mar 2015 06:53:36 +0800 From: Han Pingtian To: zsh-workers@zsh.org Subject: Re: wrong array range with (r) flag on scalar? Message-ID: <20150308225336.GA2746@localhost.localdomain> Mail-Followup-To: zsh-workers@zsh.org References: <20150305083000.GA3294@localhost.localdomain> <150305084408.ZM20963@torch.brasslantern.com> <20150305170638.0d10ba1b@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150305170638.0d10ba1b@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15030823-0029-0000-0000-0000086B8815 On Thu, Mar 05, 2015 at 05:06:38PM +0000, Peter Stephenson wrote: > couldn't resist rubbing it in at the end :-) > > pws > > > diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo > index d044f87..7b127bc 100644 > --- a/Doc/Zsh/params.yo > +++ b/Doc/Zsh/params.yo > @@ -187,7 +187,17 @@ from the end of the array tt(foo), and > Subscripting may also be performed on non-array values, in which > case the subscripts specify a substring to be extracted. > For example, if tt(FOO) is set to `tt(foobar)', then > -`tt(echo $FOO[2,5])' prints `tt(ooba)'. > +`tt(echo $FOO[2,5])' prints `tt(ooba)'. Note that > +some forms of subscripting described below perform pattern matching, > +and in that case the substring extends from the start of the match > +of the first subscript to the end of the match of the second > +subscript. For example, > + > +example(string="abcdefghijklm" > +print ${string[+LPAR()r+RPAR()d?,+LPAR()r+RPAR()h?]}) > + > +prints `tt(defghi)'. This is an obvious generalisation of the > +rule for single-character matches. > > subsect(Array Element Assignment) > Looks like this is also the case for (i): localhost% foo=abcdefgh localhost% print $foo[(r)ab,(i)fg] abcdefg localhost% Though localhost% print $foo[(i)fg] 6 localhost% But according to the new contents of manual, this is the same case as "(r)fg". Thanks.