GNU bug report logs - #19953
egrep: 'Invalid range end' - bug or not?

Previous Next

Package: coreutils;

Reported by: George Shuklin <george.shuklin <at> gmail.com>

Date: Thu, 26 Feb 2015 13:30:03 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

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 19953 in the body.
You can then email your comments to 19953 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-coreutils <at> gnu.org:
bug#19953; Package coreutils. (Thu, 26 Feb 2015 13:30:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to George Shuklin <george.shuklin <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 26 Feb 2015 13:30:05 GMT) Full text and rfc822 format available.

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

From: George Shuklin <george.shuklin <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: egrep: 'Invalid range end' - bug or not?
Date: Thu, 26 Feb 2015 15:28:51 +0200
$ echo 'sample-text'|egrep '[0-9\-a-z]'
grep: Invalid range end

but:

$ echo 'sample-text'|egrep '[0-9a-z\-]'
sample-text

(grep 2.20-4.1)




Information forwarded to bug-coreutils <at> gnu.org:
bug#19953; Package coreutils. (Thu, 26 Feb 2015 14:51:02 GMT) Full text and rfc822 format available.

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

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: George Shuklin <george.shuklin <at> gmail.com>, 19953 <at> debbugs.gnu.org
Subject: Re: bug#19953: egrep: 'Invalid range end' - bug or not?
Date: Thu, 26 Feb 2015 15:50:16 +0100
tag 19953 notabug
close 19953
stop

On 02/26/2015 02:28 PM, George Shuklin wrote:
> $ echo 'sample-text'|egrep '[0-9\-a-z]'
> grep: Invalid range end
>
> but:
>
> $ echo 'sample-text'|egrep '[0-9a-z\-]'
> sample-text
>
> (grep 2.20-4.1)

Thanks for the bug report, however you reached the wrong
list (bug-coreutils@...):

  $ egrep --help | grep bug
  Report bugs to: bug-grep <at> gnu.org

Feel free to report this there.
Meanwhile, I'm closing this as "notabug" here.

Have a nice day,
Berny




Information forwarded to bug-coreutils <at> gnu.org:
bug#19953; Package coreutils. (Thu, 26 Feb 2015 15:07:01 GMT) Full text and rfc822 format available.

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

From: Eric Blake <eblake <at> redhat.com>
To: George Shuklin <george.shuklin <at> gmail.com>, 19953 <at> debbugs.gnu.org
Subject: Re: bug#19953: egrep: 'Invalid range end' - bug or not?
Date: Thu, 26 Feb 2015 08:06:02 -0700
[Message part 1 (text/plain, inline)]
On 02/26/2015 06:28 AM, George Shuklin wrote:
> $ echo 'sample-text'|egrep '[0-9\-a-z]'
> grep: Invalid range end

There are different regex flavors.  Some, like perl, allow you to write
[...\-...] to include a literal '-' in the middle of a larger set of
characters.  But others, like the POSIX BRE (basic) and ERE (extended)
flavors do not.  In these flavors, the ONLY way to include literal '-'
in a character set is to put it at the front or at the back of the set
being enumerated.  Any appearance of '\' in the set is taken literally;
there is no way to use '\' as an escape character.

Thus, your attempt here is requesting the set consisting of the range
from '0' to '9', from '\' to 'a', and then an unexpected '-' character
that is not the end.  It is invalid per POSIX.

> 
> but:
> 
> $ echo 'sample-text'|egrep '[0-9a-z\-]'

This requests the set from '0' to '0', the set from 'a' to 'z', the
literal '\', and the literal '-'.

As Bernhard pointed out, this is not a coreutils bug.  But it is also
not a grep bug.  It is your usage that is at fault.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Oct 2018 01:49:04 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 19953 <at> debbugs.gnu.org and George Shuklin <george.shuklin <at> gmail.com> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Oct 2018 01:49:04 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 20 Nov 2018 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 214 days ago.

Previous Next


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