Bug 77799 - [:upper:] [:lower:] [:digit:]...all bafflingly broken in grep
Summary: [:upper:] [:lower:] [:digit:]...all bafflingly broken in grep
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: grep
Version: 8.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Mike McLean
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-11-13 20:31 UTC by Telsa Gwynne
Modified: 2007-04-18 16:48 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2002-11-13 22:37:07 UTC
Embargoed:


Attachments (Terms of Use)

Description Telsa Gwynne 2002-11-13 20:31:20 UTC
Description of Problem:

$ cat um
ALL CAPITALS
all little
$ grep [:upper:] um
all little
$

(and locale seems to be irrelevant here)

Version: grep-2.5.1-4

How Reproducible: always (yay!)

Steps to Reproduce:
1.  create a file with lines of only lower-case letters, only upper-case
letters, only numerals
and combinations of each 
2.  grep [:upper:] filename

Actual Results: As pasted above

Expected Results: Only lines with an upper-case character in whatever locale
you're in returned.

Additional Information:
	
I have known about this for a while now, but had always thought I was reading
the info grep
pages incorrectly.  Asking around, I find that apparently I'm using the above
(and [:alpha:] and
so on) correctly after all. I have LC_COLLATE=C in my bash_profile.  I set
LC_ALL to C just
in case and got the same results.

I am sure this was happening on at least 7.3 and possibly earlier. It's just
taken me that
long to find out that it wasn't just me being inept (unless you tell me the
contrary). It is
also happening on Debian and SuSE, in grep versions 2.4.2 and 2.5.1. I shall try
to find the
right place to report this upstream as well, but I was halfway through this
bug-report before
I found it was happening on other distros. 

Alternatively, if I am using the patterns wrongly, then I reckon it's a bug in
the info page :)

Comment 1 Telsa Gwynne 2002-11-13 22:37:00 UTC
Sigh.

It's a bug in the info page...

$ grep [[:upper:]] ../um
ALL CAPITALS
$

I honestly think this is very unclear documentation. I managed to 
confuse a lot of people with this one.

Comment 2 Tim Waugh 2002-11-14 08:49:27 UTC
"Finally, certain named classes  of  characters  are  predefined *within*
bracket expressions" (my emphasis); there's also an example.

grep [[:upper:]] um


Note You need to log in before you can comment on or make changes to this bug.