From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9650 invoked by alias); 6 Dec 2016 20:16:36 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22161 Received: (qmail 14084 invoked from network); 6 Dec 2016 20:16:36 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-8.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.72):SA:0(-0.0/5.0):. Processed in 1.697029 secs); 06 Dec 2016 20:16:36 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.72 as permitted sender) X-Originating-IP: [86.21.219.59] X-Spam: 0 X-Authority: v=2.1 cv=N5HUbDJB c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=pGLkceISAAAA:8 a=wzCobaFwjnK-VwHQxHsA:9 a=CjuIK1q_8ugA:10 a=6kGIvZw6iX1k4Y-7sg4_:22 Date: Tue, 6 Dec 2016 20:16:29 +0000 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: End Index number not what I expected Message-ID: <20161206201629.2970ef18@ntlworld.com> In-Reply-To: References: X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 6 Dec 2016 11:09:39 -0600 Jim wrote: > The man page states: > > B Include the index of the beginning of the match in the result. > E Include the index of the end of the match in the result. > > Logic to me would be, if the B flag returns the index of the first > character of the match, then the E flag should return the index > of the last character of the match, not +1. > > Am I missing something here? No. There's a test in the test suite... # This (1) doesn't work with // or / # (2) perhaps ought to be 18, to be consistent with normal zsh # substring indexing and with backreferences. print ${(BES)string##white} 0:${(BE...)...} >14 19 I think this is just an underused feature that's been allowed to get away with it. It should at least be properly documented, though it would be preferable if it was more consistent. pws diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 87ca790..cf4f69e 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -1394,7 +1394,8 @@ item(tt(B))( Include the index of the beginning of the match in the result. ) item(tt(E))( -Include the index of the end of the match in the result. +Include the index one character past the end of the match in the result +(note this is inconsistent with other uses of parameter index). ) item(tt(M))( Include the matched portion in the result.