Subject: Re: bug#23234: unexpected results with charset handling in GNU grep 2.23

From: Norihiro Tanaka <[email-masked]>
Date: Sat, 09 Apr 2016 18:29:01 +0900

On Wed, 6 Apr 2016 18:25:16 -0700
Paul Eggert <[email-masked]> wrote:

> On 04/06/2016 04:15 PM, Eric Blake wrote:
> > And yes, maybe we could change grep to print the "Binary file matches"
> > message to stderr, but that in turn will probably break other scripts,
> > and lead to even more complaints from people doing non-standard things
> > and expecting consistent results.
> 
> Yes, I'm dubious about this idea. grep's behavior was inspired by
> diff's similar behavior, and grep and diff have worked that way for
> many years and I expect people depend on it. POSIX says that diff
> should output its binary-file message to stdout, and I expect that if
> POSIX standardized grep's behavior on binary files it would do
> something similar.

Hmm, diff does not output "Binary file matches" between text files, but
grep does it.

$ cp src/grep grep.bin
$ LC_ALL=en_US.utf8 src/grep g grep.bin
Binary file grep.bin matches
$ cat >grep.bin <<EOF
Binary file grep.bin matches
EOF
$ LC_ALL=en_US.utf8 src/grep g grep.bin
Binary file grep.bin matches

When a user got "Binary file matches" from grep, he can distinguish
whether matched a binary file or a line including "Binary file matches"
of a text file from only this result.