From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1036 invoked by alias); 5 Mar 2015 17:06:45 -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: 34657 Received: (qmail 5256 invoked from network); 5 Mar 2015 17:06: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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7fc86d0000066b7-a8-54f88c8c99d1 Date: Thu, 05 Mar 2015 17:06:38 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: wrong array range with (r) flag on scalar? Message-id: <20150305170638.0d10ba1b@pwslap01u.europe.root.pri> In-reply-to: <150305084408.ZM20963@torch.brasslantern.com> References: <20150305083000.GA3294@localhost.localdomain> <150305084408.ZM20963@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGLMWRmVeSWpSXmKPExsVy+t/xq7o9PT9CDPrW8FgcbH7I5MDoserg B6YAxigum5TUnMyy1CJ9uwSujO0TW1gKnrBXHJx1k7GBcQdbFyMnh4SAicSn5YuYIWwxiQv3 1gPFuTiEBJYyStzoaGeFcJYwScxa/wTK2cYosWvlF3aQFhYBVYmjJ/6ygthsAoYSUzfNZgSx RQTEJc6uPc8CYgsLmEtMnHkVzOYVsJd4s/UAWA2ngJXEjZ4ZYKuFBDIlNn/eARbnF9CXuPr3 ExPESfYSM6+cYYToFZT4Mfke2BxmAS2JzduaWCFseYnNa95CzVGXuHF3N/sERqFZSFpmIWmZ haRlASPzKkbR1NLkguKk9FwjveLE3OLSvHS95PzcTYyQsP26g3HpMatDjAIcjEo8vAVJ30KE WBPLiitzDzFKcDArifAebPkRIsSbklhZlVqUH19UmpNafIiRiYNTqoFxo7m0W0lbgESryTaF /cwTynw3B/4663pd+d7ryVvPLpzF0r9GYtaX8G9fVCv9TE777hWMe8zFlr/B2vXlvekHPC7s j7m0vE0jwsG1RKGIpS9/fWXDQq59d41bfJu+rj7r5OCoZsYxgX/n5ms1e1bwr55qzP1Ldm2z /aRVXyLN5vE6HJd4ZqquxFKckWioxVxUnAgAnCWlCDkCAAA= 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)