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.
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.
https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=8243