Bug 118716

Summary: grep with --color and -f patternfile gives wrong results
Product: [Retired] Red Hat Linux Reporter: Thomas Steudten <tomri>
Component: grepAssignee: Tim Waugh <twaugh>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-03-22 14:21:30 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 Thomas Steudten 2004-03-19 13:51:59 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4)
Gecko/20030624 Netscape/7.1 (ax)

Description of problem:
grep called with option --color=auto works fine with
pattern matching given expr like "one|two|three", but
gives wrong results if gives the expr from file with
option -f patternfile. 
patternfile:
one
three
two

Different behavior with egrep=grep -E and grep -F...




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

How reproducible:
Always

Steps to Reproduce:
1. echo -e "one two test runs here\nok runs one test one" | egrep
--color=auto  "runs|one|test"
2. echo -e "one two test runs here\nok runs one test one" | egrep
--color=auto -f pattern
pattern: 
runs
one
test
3.
    

Actual Results:  1. one two test runs here (only two,here not highlighted)
   ok runs one test one (only ok not hl)
2. one .. (only runs hl)
   ok .. (only ok, test not hl)

Expected Results:  1. OK
2. like 1.

Additional info:

Try changing the order of the pattern in pattenfile, gives
different output.

Comment 1 Tim Waugh 2004-03-22 12:55:40 UTC
This is expected.  A pattern file is not equivalent to
line1|line2|..., but each line is matched in turn until a match is found.

Comment 2 Thomas Steudten 2004-03-22 13:15:39 UTC
No, expected - and the correct output with --color option and -f
patternfile is given from grep -F --color -f patternfile.
The wrong output and not expected output, is the bug above.

grep -E --color -f patternfile gives definitly wrong output. Without
the coloroption, you´re right. The pattern are found, and the hole
inputline is printed.

Please reopen and fix.