GNU bug report logs - #17856
Unmatched right parenthesis in ERE

Previous Next

Package: grep;

Reported by: Nathan Weeks <weeks <at> iastate.edu>

Date: Thu, 26 Jun 2014 15:36:03 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17856 in the body.
You can then email your comments to 17856 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#17856; Package grep. (Thu, 26 Jun 2014 15:36:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nathan Weeks <weeks <at> iastate.edu>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Thu, 26 Jun 2014 15:36:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nathan Weeks <weeks <at> iastate.edu>
To: bug-grep <at> gnu.org
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/




Information forwarded to bug-grep <at> gnu.org:
bug#17856; Package grep. (Fri, 27 Jun 2014 06:13:02 GMT) Full text and rfc822 format available.

Message #8 received at 17856 <at> debbugs.gnu.org (full text, mbox):

From: arnold <at> skeeve.com
To: weeks <at> iastate.edu, 17856 <at> debbugs.gnu.org
Subject: Re: bug#17856: Unmatched right parenthesis in ERE
Date: Fri, 27 Jun 2014 00:12:20 -0600
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 <weeks <at> iastate.edu> 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/
>
>




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Fri, 27 Jun 2014 19:37:02 GMT) Full text and rfc822 format available.

Notification sent to Nathan Weeks <weeks <at> iastate.edu>:
bug acknowledged by developer. (Fri, 27 Jun 2014 19:37:03 GMT) Full text and rfc822 format available.

Message #13 received at 17856-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: arnold <at> skeeve.com, weeks <at> iastate.edu, 17856-done <at> debbugs.gnu.org
Subject: Re: bug#17856: Unmatched right parenthesis in ERE
Date: Fri, 27 Jun 2014 12:35:48 -0700
[Message part 1 (text/plain, inline)]
arnold <at> skeeve.com 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 (text/plain, attachment)]

Information forwarded to bug-grep <at> gnu.org:
bug#17856; Package grep. (Fri, 27 Jun 2014 23:08:02 GMT) Full text and rfc822 format available.

Message #16 received at 17856 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: 17856 <at> debbugs.gnu.org, Paul Eggert <eggert <at> cs.ucla.edu>, weeks <at> iastate.edu
Cc: 17856-done <at> debbugs.gnu.org, Aharon Robbins <arnold <at> skeeve.com>
Subject: Re: bug#17856: Unmatched right parenthesis in ERE
Date: Fri, 27 Jun 2014 16:06:40 -0700
On Fri, Jun 27, 2014 at 12:35 PM, Paul Eggert <eggert <at> cs.ucla.edu> wrote:
> arnold <at> skeeve.com 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.

And thank you for the complete fix, Paul.




Information forwarded to bug-grep <at> gnu.org:
bug#17856; Package grep. (Fri, 27 Jun 2014 23:08:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-grep <at> gnu.org:
bug#17856; Package grep. (Mon, 30 Jun 2014 14:53:02 GMT) Full text and rfc822 format available.

Message #22 received at 17856 <at> debbugs.gnu.org (full text, mbox):

From: Sekar Sundaram <inventsekarinfo <at> gmail.com>
To: Jim Meyering <jim <at> meyering.net>
Cc: weeks <at> iastate.edu, 17856 <at> debbugs.gnu.org, Paul Eggert <eggert <at> cs.ucla.edu>,
 17856-done <at> debbugs.gnu.org
Subject: Re: bug#17856: Unmatched right parenthesis in ERE
Date: Mon, 30 Jun 2014 09:52:37 -0500
[Message part 1 (text/plain, inline)]
Good Day to all... i am sure you have checked this... just in case, if u
have missed, let me write this...  (am a newbie, apologies if something
wrong in my findings)


invent <at> sekar:~> echo "(" | grep "("

(

invent <at> sekar:~> echo ")" | grep ")"

)



invent <at> sekar:~> echo ")" | grep -E ")"

grep: Unmatched ) or \)

invent <at> sekar:~> echo ")" | grep -E "\)"

)

invent <at> sekar:~> echo "(" | grep -E "("

grep: Unmatched ( or \(

invent <at> sekar:~> echo "(" | grep -E "\("

(



invent <at> sekar:~> echo "(" | grep -e "("

(

invent <at> sekar:~> echo ")" | grep -e ")"

)

invent <at> sekar:~> echo ")" | grep -e "\)"

grep: Unmatched ) or \)

invent <at> sekar:~> echo "(" | grep -e "\("

grep: Unmatched ( or \(


thanks, Have a splendid day!

*Best Regards,*

*invent Sekar *

*The smallest things can have the biggest impact. Look inside. - Intel*
[Message part 2 (text/html, inline)]

Information forwarded to bug-grep <at> gnu.org:
bug#17856; Package grep. (Mon, 30 Jun 2014 14:53:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-grep <at> gnu.org:
bug#17856; Package grep. (Thu, 24 Jul 2014 20:06:02 GMT) Full text and rfc822 format available.

Message #28 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Aharon Robbins <arnold <at> skeeve.com>
To: eggert <at> cs.ucla.edu
Cc: bug-grep <at> gnu.org
Subject: Re: bug#17856: Unmatched right parenthesis in ERE
Date: Thu, 24 Jul 2014 16:05:23 -0400
Catching up on old mail...

> Date: Fri, 27 Jun 2014 12:35:48 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> To: arnold <at> skeeve.com, weeks <at> iastate.edu, 17856-done <at> debbugs.gnu.org
> Subject: Re: bug#17856: Unmatched right parenthesis in ERE
>
> arnold <at> skeeve.com 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.

Actually, I suspect that they'd be willing to accept updates to those
macros.  I don't think any could be removed, but we should be able to
get them fixed.

Thanks,

Arnold




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 22 Aug 2014 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 249 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.