From: Philippe Altherr <firstname.lastname@example.org>
To: Bart Schaefer <email@example.com>
Cc: Peter Stephenson <firstname.lastname@example.org>,
Zsh hackers list <email@example.com>
Subject: Re: Subscript flag (i) not working correctly on empty strings?
Date: Sat, 7 Jan 2023 14:45:50 +0100 [thread overview]
Message-ID: <CAGdYchvfrrRAxdMybUbs8JTj3ii464pxnGptHAUUoiw4xYv8Zw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1512 bytes --]
Thanks for the fix.
For the record, I was trying to do something like this:
> if [[ $separator_index -le $#input ]]; then
> # Found separator
Currently, an empty input incorrectly triggers the conditional code. To
avoid it, an extra condition for that specific case is required, which is
In the code above, an alternative would be to use (I) and test against 0,
which works in all cases, but it feels wrong in my code where I also need
the index of the *first* separator.
On Fri, Jan 6, 2023 at 7:12 PM Bart Schaefer <firstname.lastname@example.org>
> On Fri, Jan 6, 2023 at 9:24 AM Peter Stephenson
> <email@example.com> wrote:
> > > On 06/01/2023 16:01 Philippe Altherr <firstname.lastname@example.org>
> > >
> > > > s=; echo $s[(i)z];
> > >
> > > > 0
> > >
> > > Why is the last line 0 and not 1?
> > Certainly looks plain wrong.
> > None of the existing tests fail with this change.
> I thought there was a discussion about this at some point in the past
> ... but it may have been limited to array cases. I have the feeling
> we concluded that (i) and (I) should produce the same result on empty
> string for purposes of boolean tests, but I can't find such a
> conversation in the archives. I remain a little concerned that some
> scripts are going to unexpectedly break, but can't point to anything,
> and $anUnsetName[(i)z] returns nothing rather than 0, so it's probably
> an unfounded worry.
[-- Attachment #2: Type: text/html, Size: 2342 bytes --]
next prev parent reply other threads:[~2023-01-07 13:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-06 16:01 Philippe Altherr
2023-01-06 17:23 ` Peter Stephenson
2023-01-06 18:12 ` Bart Schaefer
2023-01-07 13:45 ` Philippe Altherr [this message]
2023-01-07 13:52 ` Roman Perepelitsa
2023-01-07 13:54 ` Roman Perepelitsa
2023-01-08 19:47 ` Peter Stephenson
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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
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).