Subject: bug#51669: closed (Re: bug#51669: some patterns which should match 0x0 don’t do so)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 08 Nov 2021 00:38:01 +0000

Your bug report

#51669: some patterns which should match 0x0 don’t do so

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].

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

Subject: Re: bug#51669: some patterns which should match 0x0 don’t do so
From: Paul Eggert <[email-masked]>
To: Christoph Anton Mitterer <[email-masked]>
Cc: [email-masked]
Date: Sun, 7 Nov 2021 16:37:17 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

That's a feature not a bug; see:

https://www.gnu.org/software/grep/manual/html_node/File-and-Directory-Selection.html

and look for --binary-files. You can use 'grep -a' to pay more attention 
to binary data.

Subject: some patterns which should match 0x0 don’t do so
From: Christoph Anton Mitterer <[email-masked]>
To: [email-masked]
Date: Sun, 07 Nov 2021 17:56:56 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hey.

Maybe this is no a bug at all due grep rather being focused on text
files and 0x0 being special anyway, but just for your information:

$ hd test-with-0x00-and-0x02 
00000000  66 6f 6f 0a 62 61 72 0a  7a 65 02 00 0a 62 61 7a  |foo.bar.ze...baz|
00000010  0a 7a 65 72 00 0a 65 6e  64 0a                    |.zer..end.|
0000001a

If one now does:
$ grep '[^[:alnum:][:space:][:punct:]]' test-with-0x00-and-0x02
grep: test-with-0x00-and-0x02: binary file matches

it matches, presumably only the 0x02, though.

Having only 0x00 in the file:
$ hd test-with-0x00-only
00000000  66 6f 6f 0a 62 61 72 0a  7a 65 72 00 0a 62 61 7a  |foo.bar.zer..baz|
00000010  0a 7a 65 72 00 0a 65 6e  64 0a                    |.zer..end.|
0000001a

doesn’t cause a match:
$ grep '[^[:alnum:][:space:][:punct:]]' test-with-0x00-only
$

while naively I'd have assume that 0x00 should be matched as well.

Cheers,
Chris.