From: Roman Perepelitsa <roman.perepelitsa@gmail.com>
To: Philippe Altherr <philippe.altherr@gmail.com>
Cc: Bart Schaefer <schaefer@brasslantern.com>,
Peter Stephenson <p.w.stephenson@ntlworld.com>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Subscript flag (i) not working correctly on empty strings?
Date: Sat, 7 Jan 2023 14:52:02 +0100 [thread overview]
Message-ID: <CAN=4vMoQNwiFV6_hgbPMvr4F=ESpdmg-qVuRKMtazp-aHzov1Q@mail.gmail.com> (raw)
In-Reply-To: <CAGdYchvfrrRAxdMybUbs8JTj3ii464pxnGptHAUUoiw4xYv8Zw@mail.gmail.com>
On Sat, Jan 7, 2023 at 2:46 PM Philippe Altherr
<philippe.altherr@gmail.com> wrote:
>
> Thanks for the fix.
>
> For the record, I was trying to do something like this:
>
>> separator_index=$input[(i):]
>> if [[ $separator_index -le $#input ]]; then
>> # Found separator
>> ...
>> fi
Whenever I need to check whether a string/array contains a
character/element, I do it like this:
if (( $input[(I):] )); then
print 'input contains colon'
fi
It's nice that $input is referenced only once. It's also nice that the
"contains" condition has no operators.
Roman.
next prev parent reply other threads:[~2023-01-07 13:52 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
2023-01-07 13:52 ` Roman Perepelitsa [this message]
2023-01-07 13:54 ` Roman Perepelitsa
2023-01-08 19:47 ` Peter Stephenson
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='CAN=4vMoQNwiFV6_hgbPMvr4F=ESpdmg-qVuRKMtazp-aHzov1Q@mail.gmail.com' \
--to=roman.perepelitsa@gmail.com \
--cc=p.w.stephenson@ntlworld.com \
--cc=philippe.altherr@gmail.com \
--cc=schaefer@brasslantern.com \
--cc=zsh-workers@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).