Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Subscript flag (i) not working correctly on empty strings?
On Sat, Jan 7, 2023 at 2:46 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author