GNU bug report logs - #51669
some patterns which should match 0x0 don’t do so

Previous Next

Package: grep;

Reported by: Christoph Anton Mitterer <calestyo <at> scientia.org>

Date: Sun, 7 Nov 2021 17:30:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#51669: closed (some patterns which should match 0x0
 don’t do so)
Date: Mon, 08 Nov 2021 00:38:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 7 Nov 2021 16:37:17 -0800
with message-id <1158bc7b-f8d4-e692-1af0-1767edf7b630 <at> cs.ucla.edu>
and subject line Re: bug#51669: some patterns which should match 0x0 don’t do so
has caused the debbugs.gnu.org bug report #51669,
regarding some patterns which should match 0x0 don’t do so
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
51669: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=51669
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Christoph Anton Mitterer <calestyo <at> scientia.org>
To: bug-grep <at> gnu.org
Subject: some patterns which should match 0x0 don’t do so
Date: Sun, 07 Nov 2021 17:56:56 +0100
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.


[Message part 3 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Christoph Anton Mitterer <calestyo <at> scientia.org>
Cc: 51669-done <at> debbugs.gnu.org
Subject: Re: bug#51669: some patterns which should match 0x0 don’t do so
Date: Sun, 7 Nov 2021 16:37:17 -0800
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.


This bug report was last modified 3 years and 254 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.