--- Begin Message ---
Subject: |
Unmatched right parenthesis in ERE |
Date: |
Thu, 26 Jun 2014 08:10:29 -0500 |
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/
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#17856: Unmatched right parenthesis in ERE |
Date: |
Fri, 27 Jun 2014 12:35:48 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
address@hidden wrote:
Y'all might want to consider basing RE_SYNTAX_POSIX_EGREP
off of RE_SYNTAX_POSIX_EXTENDED; that would have gotten this case.
At some point we should clean out those old RE_SYNTAX_* macros; half of
them are just plain wrong anyway. However, doing that will require a
fix to glibc, which would take quite a long time to propagate through,
and in the meantime the attached patch should suffice. I've installed
it and it should appear in the next grep release. Thanks for reporting
the bug, Nathan.
0001-grep-with-E-unmatched-matches-itself.patch
Description: Text document
--- End Message ---