Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Handling of escaped plus sign ("+") in regular expressions



Hi,

I've been using zsh to run some local scripts I was normally running with
bash and while most of them work as expected, there's a case that weirdly
failed to me (using zsh 5.8):

[[ +123 =~ ^+[0-9]+$ ]]
zsh: failed to compile regex: Invalid preceding regular expression

[[ +123 =~ ^\+[0-9]+$ ]]
zsh: failed to compile regex: Invalid preceding regular expression

The same behavior seems to apply both using RE_MATCH_PCRE and not.
As said, both matches correctly using bash.

Using something like

[[ +123 =~ ^[+][0-9]+$ ]]

Works as expected instead.


Messages sorted by: Reverse Date, Date, Thread, Author