Issue with Bash RegEx Handling
Gerhard Jäger
gja@sysgo.com
Mon Jul 6 09:15:13 GMT 2026
On 03.07.26 at 23:27 Keith Thompson wrote:
> I've reproduced the problem, and it appears to be a change in the
> newlib regular expression implementation, for a case that POSIX
> leaves undefined.
>
> I have bash 5.3 built from source, which apparently is a bit more
> verbose than the default /usr/bin/bash.exe.
>
> Here's a simpler example:
>
> $ [[ x =~ ^(foo|)$ ]] ; echo $?
> bash: [[: invalid regular expression `^(foo|)$': empty (sub)expression
> 2
> $ [[ '' =~ ^(foo|)$ ]] ; echo $?
> bash: [[: invalid regular expression `^(foo|)$': empty (sub)expression
> 2
> $·
>
> The expected result is 1 (no match) for the first and 0 (match) for
> the second. A result of 2 indicates an invalid regular expression.
[...]
Thank you for sheding some light on this. It's unfortunate that such
expressions work on older versions, but undefined remains undefined :(
Regards,
Gerhard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3058 bytes
Desc: Kryptografische S/MIME-Signatur
URL: <https://cygwin.com/pipermail/cygwin/attachments/20260706/663c6e78/attachment.p7s>
More information about the Cygwin
mailing list