Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Can I test if a parameter expansion has worked
2022-09-20 14:25:51 +0100, Stephane Chazelas:
[...]
> ITYM
>
> if [[ $f =~ '\.(jpe?g|gif|png)$' ]]
[...]
Which, btw, if the rematchpcre option is on must be changed to:
if [[ $f =~ '\.(jpe?g|gif|png)\z' ]]
As otherwise, that would match on f=$'foo.gif\n' for instance.
With rematchpcre, see also:
$ f=$'St\xe9phane.jpg'
$ [[ $f =~ '\.(jpe?g|gif|png)\z' ]]
zsh: pcre_exec() error [-10]
Not fixed with:
$ LC_ALL=C [ "$f" '=~' '\.(jpe?g|gif|png)\z' ]
zsh: pcre_exec() error [-10]
(bug?)
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author