Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 81521 - grep outputs mismatched patterns
Summary: grep outputs mismatched patterns
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: grep
Version: 8.0
Hardware: i686
OS: Linux
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Mike McLean
Depends On:
TreeView+ depends on / blocked
Reported: 2003-01-10 02:59 UTC by Zhao Wu
Modified: 2007-03-27 03:59 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2003-01-10 09:38:18 UTC

Attachments (Terms of Use)

Description Zhao Wu 2003-01-10 02:59:03 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)

Description of problem:
When I use regular expression in grep, it outputs lines which do not contain 
the specified patterns.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
Just try the following at shell prompt:
echo "foo" |grep "[L-Z]"

Actual Results:  foo

Expected Results:  nothing should be output

Additional info:

At first, I thought it was a case-sensitivity problem, but later I found more 
problems. Note that in the above example, letter 'f' is not even in the list [l-
z]. grep is being constantly used by many scripts and programs, and this bug 
leads to a potential security breach.

Comment 1 Zhao Wu 2003-01-10 03:01:44 UTC
I forgot to mention that this is a new bug in Redhat 8.0. I tried on 7.3 and 
there is no such a bug.

Comment 2 Tim Waugh 2003-01-10 09:38:18 UTC
You forgot to set LC_COLLATE.  See the bash FAQ question E9.

Comment 3 Zhao Wu 2003-01-10 19:38:15 UTC
Thanks for the FAQ info. LC_COLLATE works, but why does "foo" match "[L-Z]" 
even though 'f' is not in "lLmMnN...zZ"? Isn't that a bug?

Comment 4 Tim Waugh 2003-01-10 22:54:13 UTC
Because 'o' is.

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