GNU bug report logs - #22820
grep: Misleading error message when presenting a badly formed character class

Previous Next

Package: grep;

Reported by: santiagorr <at> riseup.net

Date: Fri, 26 Feb 2016 14:52:02 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

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 22820 in the body.
You can then email your comments to 22820 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#22820; Package grep. (Fri, 26 Feb 2016 14:52:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to santiagorr <at> riseup.net:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Fri, 26 Feb 2016 14:52:02 GMT) Full text and rfc822 format available.

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

From: santiagorr <at> riseup.net
To: bug-grep <bug-grep <at> gnu.org>
Subject: grep: Misleading error message when presenting a badly formed
 character class
Date: Fri, 26 Feb 2016 15:51:18 +0100
Hi,

I'd like to forward a bug filled by Gunnar Wolf in Debian some time
ago:

"It seems that whenever egrep finds something it cannot digest inside a
character class, it spews out the same error string: «Unmatched [ or [^».
This can be misleading and opens the way for long debugging time,
specially when trying to understand complex regexes. To illustrate the
point:

$ echo | egrep -v '[[:digit]]+'
egrep: Unmatched [ or [^

The brackets _are_ balanced, however the character class is not (it
lacks a finishing colon)."

Thanks,

Santiago




Reply sent to Jim Meyering <jim <at> meyering.net>:
You have taken responsibility. (Fri, 26 Feb 2016 16:50:02 GMT) Full text and rfc822 format available.

Notification sent to santiagorr <at> riseup.net:
bug acknowledged by developer. (Fri, 26 Feb 2016 16:50:02 GMT) Full text and rfc822 format available.

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

From: Jim Meyering <jim <at> meyering.net>
To: Bailes Magio <santiagorr <at> riseup.net>
Cc: 22820-done <at> debbugs.gnu.org
Subject: Re: bug#22820: grep: Misleading error message when presenting a badly
 formed character class
Date: Fri, 26 Feb 2016 08:49:32 -0800
On Fri, Feb 26, 2016 at 6:51 AM,  <santiagorr <at> riseup.net> wrote:
> Hi,
>
> I'd like to forward a bug filled by Gunnar Wolf in Debian some time
> ago:
>
> "It seems that whenever egrep finds something it cannot digest inside a
> character class, it spews out the same error string: «Unmatched [ or [^».
> This can be misleading and opens the way for long debugging time,
> specially when trying to understand complex regexes. To illustrate the
> point:
>
> $ echo | egrep -v '[[:digit]]+'
> egrep: Unmatched [ or [^
>
> The brackets _are_ balanced, however the character class is not (it
> lacks a finishing colon)."

Thank you for forwarding that.
The diagnostic was fixed in gnulib via a commit last month:
git.savannah.gnu.org/cgit/gnulib.git/commit/?id=7c6e85cf4eccbd5129
Thus, as long as grep is configured --with-included-regex,
you will now see this:

  $ grep -E '[[:digit]]+'
  grep: Unmatched [, [^, [:, [., or [=

If grep is configure with --without-included-regex, you will
still see the inferior diagnostic, but that string will then be
coming from your system's C library.

Since fixing glibc's copy of regcomp.c is outside the scope
of grep's issue tracker, I'm marking this as "done".




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

This bug report was last modified 8 years and 55 days ago.

Previous Next


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