Subject: Re: bug#62483: echo a | grep -E -w '((()|a)|())*' # does not terminate

From: Carlo Arenas <[email-masked]>
Date: Sun, 2 Apr 2023 13:23:54 -0700

On Sun, Apr 2, 2023 at 11:30 AM Paul Eggert <[email-masked]> wrote:
>
> Also, GNU grep -w passes the following more-complicated regexp to dfaparse:

but AFAIK `-w` is not necessary to trigger it, as the following also
infloops in Fedora Rawhide

  $ echo a | grep -E '((()|a)|())+'

interestingly; the loop is broken if any character is added to any of
the `()` branches which might mean that this is also unlikely to
happen in well formed expressions.

Carlo

PS. -P doesn't loop and neither does `echo a | grep -E '((a|())|())+'`
nor '(()|(a|()))+` nor `(()|(()|a))+'`