Bug 77799 - [:upper:] [:lower:] [:digit:]...all bafflingly broken in grep
[:upper:] [:lower:] [:digit:]...all bafflingly broken in grep
Product: Red Hat Linux
Classification: Retired
Component: grep (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Mike McLean
Depends On:
  Show dependency treegraph
Reported: 2002-11-13 15:31 EST by Telsa Gwynne
Modified: 2007-04-18 12:48 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-11-13 17:37:07 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Telsa Gwynne 2002-11-13 15:31:20 EST
Description of Problem:

$ cat um
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 17:37:00 EST

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

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

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 03:49:27 EST
"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.