Subject: bug#33898: closed (grep reports binary file matches even with -I option)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 21 Jan 2019 03:45:02 +0000

Your bug report

#33898: grep reports binary file matches even with -I option

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
33898: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=33898
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: grep reports binary file matches even with -I option
From: Paul Eggert <[email-masked]>
To: Britton Kerin <[email-masked]>
Cc: [email-masked]
Date: Sun, 20 Jan 2019 19:43:55 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks for reporting the problem. This is a bug in grep's man page, which wasn't 
updated back in 2016 when I updated the main documentation. (The man page is 
lower priority and is sometimes neglected.) I installed the attached patch to 
fix it.
>From f3b521b87d178205811a22aff2974d77f1aa3054 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sun, 20 Jan 2019 19:38:32 -0800
Subject: [PATCH] doc: --binary-files update in man page

* doc/grep.in.1: Adjust --binary-files description to match that
in doc/grep.texi.  When I updated the documentation in
2016-09-09T01:33:[email-masked] I forgot to update the man
page accordingly (Bug#33898).
---
 doc/grep.in.1 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/doc/grep.in.1 b/doc/grep.in.1
index 9d0d494..dd25589 100644
--- a/doc/grep.in.1
+++ b/doc/grep.in.1
@@ -505,11 +505,14 @@ By default,
 .I TYPE
 is
 .BR binary ,
-and when
+and
+.B grep
+suppresses output after null input binary data is discovered,
+and suppresses output lines that contain improperly encoded data.
+When some output is suppressed,
 .B grep
-discovers that a file is binary it suppresses any further output, and
-instead outputs either a one-line message saying that a binary file
-matches, or no message if there is no match.
+follows any output
+with a one-line message saying that a binary file matches.
 .IP
 If
 .I TYPE
@@ -517,7 +520,7 @@ is
 .BR without\-match ,
 when
 .B grep
-discovers that a file is binary it assumes that the rest of the file
+discovers null input binary data it assumes that the rest of the file
 does not match; this is equivalent to the
 .B \-I
 option.
-- 
2.17.1

Subject: grep reports binary file matches even with -I option
From: Britton Kerin <[email-masked]>
To: [email-masked]
Date: Fri, 28 Dec 2018 13:25:23 -0900
List-Id: <debbugs-submit.debbugs.gnu.org>

The man page description of the -I option implies that grep might
output match information for a
binary file if it hasn't "discovered" that the file is binary yet.  It
seems that even with -I Binary file
matches may be reported, as this example on the attached file shows:

$ 'grep' -I -e '.' bca9b83eeb33810a61cca0485f504f98540156
Binary file bca9b83eeb33810a61cca0485f504f98540156 matches

This seems like a bug, because it's clearly produced at a point when
grep has already decided the
file is binary, and scripts can reasonably expect that any matches
that do occur in a
so-far-unknown-to-be-binary file will conform to the output format
specified by other other options (e.g. -n) and feature an actual file
name.

Britton