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:54:03 +0100 [thread overview]
Message-ID: <CAN=4vMrNa87uWqJtmDqwAdnOOSF5KhzwhHs0a7s7SOqutZPULw@mail.gmail.com> (raw)
In-Reply-To: <CAN=4vMoQNwiFV6_hgbPMvr4F=ESpdmg-qVuRKMtazp-aHzov1Q@mail.gmail.com>
On Sat, Jan 7, 2023 at 2:52 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> 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
Correction: for strings I use pattern matching.
if [[ $input == *:* ]]; then
print 'input contains colon'
fi
The code I posted above is for arrays (even though it works for strings, too).
Roman.
next prev parent reply other threads:[~2023-01-07 13:54 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
2023-01-07 13:54 ` Roman Perepelitsa [this message]
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=4vMrNa87uWqJtmDqwAdnOOSF5KhzwhHs0a7s7SOqutZPULw@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).