zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: End Index number not what I expected
Date: Tue, 6 Dec 2016 20:16:29 +0000	[thread overview]
Message-ID: <20161206201629.2970ef18@ntlworld.com> (raw)
In-Reply-To: <CA+rB6GLXS6Tmtki4ns2vejy_WU79UcmCZZzGYNX71d5+Znq5fg@mail.gmail.com>

On Tue, 6 Dec 2016 11:09:39 -0600
Jim <linux.tech.guy@gmail.com> 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.


  reply	other threads:[~2016-12-06 20:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06 17:09 Jim
2016-12-06 20:16 ` Peter Stephenson [this message]
     [not found] ` <20161206201629.2970ef18__5617.78782071105$1481055469$gmane$org@ntlworld.com>
2016-12-10 14:56   ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161206201629.2970ef18@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).