Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 194938 - sys-apps/grep sometimes displays blank lines instead of search results with DOS newlines
Summary: sys-apps/grep sometimes displays blank lines instead of search results with D...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: https://savannah.gnu.org/bugs/?25539
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-06 22:12 UTC by A.C.Heron
Modified: 2014-01-02 19:31 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
A n example file where grep fails (grep-testcase.txt,176 bytes, application/octet-stream)
2007-10-06 22:17 UTC, A.C.Heron
Details

Note You need to log in before you can comment on or make changes to this bug.
Description A.C.Heron 2007-10-06 22:12:35 UTC
Grep sometimes displays empty lines instead of search results.

Reproducible: Always

Steps to Reproduce:
Give a command like 
grep 's.*' grep-testcase.txt

Actual Results:  
Displays an empty line for each line in the file 'grep-testcase.txt' with the letter 's'.

Expected Results:  
Should display lines containing the letter 's' with the fragment from the first 's' to the end of the line highlighted. 

I was able to reproduce it only on files with DOS/Windows end-of-line (0d 0a).
Comment 1 A.C.Heron 2007-10-06 22:17:27 UTC
Created attachment 132773 [details]
A n example file where grep fails

grep 's.*' grep-testcase.txt gives 5 empty lines, and so does grep -P 's.*'  grep-testcase.txt . grep -P 's.*\n' grep-testcase.txt works.
Comment 2 A.C.Heron 2008-11-10 20:41:49 UTC
The problem remains in sys-apps/grep-2.5.3

The output looks OK with --colour=never switch. Maybe the problem is with highlighting the text?

Vanilla grep 2.5.1 and 2.5.3 from gnu.org works fine.
Comment 3 SpanKY gentoo-dev 2009-02-10 05:58:52 UTC
use `dos2unix` on the file first and it'll work fine
Comment 4 A.C.Heron 2009-02-18 04:25:10 UTC
It's hard to use dos2unix on read-only files. But --colour=never seems to be enough.
Comment 5 SpanKY gentoo-dev 2010-03-23 21:10:48 UTC
running sed on a read-only file and piping it into grep works fine too

grep-2.6 is still broken (as expected)
Comment 6 SpanKY gentoo-dev 2014-01-02 19:31:34 UTC
i'm not sure this will ever really get fixed ... it's a crap situation.  see this for more info:
http://git.savannah.gnu.org/cgit/grep.git/tree/src/main.c?id=88d65410f7aa472c66da1bdf01c3cc1439cefce6#n142

you should be able to workaround it by doing:
 export GREP_COLORS=ne

in your ~/.bash_profile or wherever