Red Hat Bugzilla – Bug 118716
grep with --color and -f patternfile gives wrong results
Last modified: 2007-04-18 13:04:27 EDT
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.
Different behavior with egrep=grep -E and grep -F...
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. echo -e "one two test runs here\nok runs one test one" | egrep
2. echo -e "one two test runs here\nok runs one test one" | egrep
--color=auto -f pattern
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.
Try changing the order of the pattern in pattenfile, gives
This is expected. A pattern file is not equivalent to
line1|line2|..., but each line is matched in turn until a match is found.
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.