[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk: {} repetition in patterns doesn't work?
From: |
tt |
Subject: |
Re: gawk: {} repetition in patterns doesn't work? |
Date: |
22 Mar 2001 10:28:05 +0200 |
address@hidden (Paul Eggert) writes:
> > echo 'aa' | awk '/a{2}/'
> The POSIX requirement is widely ignored, because it causes problems
> with patterns that contain stray '{' characters.
> gawk should do what GNU grep does: namely, support the POSIX
> requirement only when it is absolutely required, and otherwise treat
> stray braces as literal braces. POSIX allows this behavior. Here is
> a quote from the grep manual that should help explain things better:
>
> GNU `egrep' attempts to support traditional usage by assuming that
> `{' is not special if it would be the start of an invalid interval
> specification. For example, the shell command `egrep '{1'' searches
> for the two-character string `{1' instead of reporting a syntax error
> in the regular expression. POSIX.2 allows this behavior as an
> extension, but portable scripts should avoid it.
>
> On my list of things to do is to add support for this to GNU regexp.c.
> That should make it easy to fix gawk to be POSIX-compliant here.
That would indeed give the best of both worlds!
Thank you for the explanation,
--
Tapani Tarvainen