[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17856: Unmatched right parenthesis in ERE
From: |
arnold |
Subject: |
bug#17856: Unmatched right parenthesis in ERE |
Date: |
Fri, 27 Jun 2014 00:12:20 -0600 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
Probably "just" a matter of adding RE_UNMATCHED_RIGHT_PAREN_ORD
into the list for RE_SYNTAX_EGREP in regex.h.
Hmm. Y'all might want to consider basing RE_SYNTAX_POSIX_EGREP
off of RE_SYNTAX_POSIX_EXTENDED; that would have gotten this case.
(Lordy, lordy, lordy, do I hate the syntax bits.)
HTH,
Arnold
Nathan Weeks <address@hidden> wrote:
> GNU grep 2.20 disallows the use of an unmatched right parenthesis in
> an extended regular expression:
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> $ echo ')' | grep -E ')'
> grep: Unmatched ) or \)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Other greps I've tried (AST grep 2014-01-06, BusyBox 1.22.1 grep, BSD
> grep 2.5.1-FreeBSD on OS X 10.8, /usr/xpg4/bin/grep on Solaris
> 11.2-beta) accept ')' as a valid ERE.
>
> POSIX apparently allows an unmatched right parenthesis in this
> context, as section 9.4.3 (ERE Special Characters;
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04_03)
> states:
>
> "The <right-parenthesis> shall be special when matched with a preceding
> <left-parenthesis>, both outside a bracket expression."
>
> and in section 9.5.1 (BRE/ERE Grammar Lexical Conventions)
> (http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_05_01),
> the description of the "SPEC_CHAR" token contains the following
> exception:
>
> "The close-parenthesis shall be considered special in this context only if
> matched with a preceding open-parenthesis."
>
> --
> Nathan Weeks
> IT Specialist
> USDA-ARS Corn Insects and Crop Genetics Research Unit
> Crop Genome Informatics Laboratory
> Iowa State University
> http://weeks.public.iastate.edu/
>
>