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

Summary: grep outputs mismatched patterns
Product: [Retired] Red Hat Linux Reporter: Zhao Wu <zhao_wu>
Component: grepAssignee: Tim Waugh <twaugh>
Status: CLOSED NOTABUG QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: high    
Version: 8.0Keywords: Security
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-01-10 09:38:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

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:
Always

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.