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