Bug 77799

Summary: [:upper:] [:lower:] [:digit:]...all bafflingly broken in grep
Product: [Retired] Red Hat Linux Reporter: Telsa Gwynne <hobbit>
Component: grepAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-11-13 22:37:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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