To me, this behavior is logical, because it assumes that the lack of
a matching brace indicates that the author of the expression simply
wasn't intending to use the repetition syntax at all.  That would follow
an intuition like "metacharacters are only metacharacters if they're
used within a correct context".

But it's inconsistent with the treatment of [], where the opening
bracket is always a metacharacter regardless of whether it's used
to introduce a valid character-class expression.

$ echo 'hello{' | egrep '{'
hello{
$ echo 'hello[' | egrep '['
grep: Invalid regular expression



Reply via email to