bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24347: Bug when grepping a text file with some arbitrary binary data


From: Karl Berry
Subject: bug#24347: Bug when grepping a text file with some arbitrary binary data
Date: Mon, 12 Sep 2016 22:16:12 GMT

    Either of the following shell commands should work with grep 2.25: 
    LC_ALL=C grep 31325 test
    grep -a 31325 test

In my grep 2.25 (compiled from original source), these two commands are
not equivalent.  (This is on 32-bit or 64-bit GNU/Linux, though I doubt
the platform matters.)

$ LC_ALL=C \grep x /bin/cat|head -1
Binary file /bin/cat matches
$

$ LC_ALL=C \grep -a x /bin/cat|head -1
^?ELF ... many binary bytes ...
$

IMHO, it would be desirable if LC_ALL=C really did grep the file,
just like -a.  And, reading the NEWS file for 2.25, it seems that is
what is intended.  Maybe I'm missing something.


Another (orthogonal) idea: provide a configure-time option to make the
default be the equivalent of -a.  I wouldn't argue that it should be the
default (though I wouldn't argue against it either :), but such an
option would make it easy for those of us who just want grep to be grep,
and not be affected by the binary/text detection heuristics. -k






reply via email to

[Prev in Thread] Current Thread [Next in Thread]