GNU bug report logs - #73360
Error when a long list is provided to grep with "--binary-files=without-match" option

Previous Next

Package: grep;

Reported by: Rodrigo Jorge <rodrigoaraujorge <at> gmail.com>

Date: Thu, 19 Sep 2024 14:29:04 UTC

Severity: normal

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

Bug is archived. No further changes may be made.

Full log


Message #14 received at 73360 <at> debbugs.gnu.org (full text, mbox):

From: "David G. Pickett" <dgpickett <at> aol.com>
To: "73360 <at> debbugs.gnu.org" <73360 <at> debbugs.gnu.org>, 
 Rodrigo Jorge <rodrigoaraujorge <at> gmail.com>
Subject: Re: bug#73360: Error when a long list is provided to grep with
 "--binary-files=without-match" option
Date: Fri, 20 Sep 2024 13:32:03 +0000 (UTC)
[Message part 1 (text/plain, inline)]
 While the output may be bulky, on Linux you can try the strace command to see exactly what it is up to.  It will show the execvp() call, for instance.  You might need a bigger -s!
$ strace -f -v -s 262144 <YOUR_CMD>

    On Thursday, September 19, 2024 at 10:29:30 AM EDT, Rodrigo Jorge <rodrigoaraujorge <at> gmail.com> wrote:   

 Hello. I'm trying to use grep to get the list of all non-binary files in a
given folder. I tried with the 2.20 and the 3.11 release.

For some reason, grep is providing 2 false negatives when the list is huge.
This issue does not happen if I break the grep input with "xargs -n X".

Check below:

[opc <at> oradiff-core dbhome_1]$ grep -V
grep (GNU grep) 3.11
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <
https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others; see
<https://git.savannah.gnu.org/cgit/grep.git/tree/AUTHORS>.

[opc <at> oradiff-core dbhome_1]$ find -type f -not -path "./.patch_storage/*"
-not -name "tfa_setup" -print0 2>> /tmp/error.list | xargs -0 -n 100 grep
-Il '.' > /tmp/list1.list

[opc <at> oradiff-core dbhome_1]$ find -type f -not -path "./.patch_storage/*"
-not -name "tfa_setup" -print0 2>> /tmp/error.list | xargs -0 grep -Il '.'
> /tmp/list2.list

[opc <at> oradiff-core dbhome_1]$ diff /tmp/list1.list /tmp/list2.list
12268,12269d12267
< ./apex/images/apex_ui/psd/apex_5_ui.ai
< ./apex/images/apex_ui/psd/apex-logo.ai

[opc <at> oradiff-core dbhome_1]$ wc -l /tmp/list1.list /tmp/list2.list
  23397 /tmp/list1.list
  23395 /tmp/list2.list
  46792 total

The output should not show any difference.

The same issue was also reproduced in grep 2.20.

Thanks,
Rodrigo
  
[Message part 2 (text/html, inline)]

This bug report was last modified 298 days ago.

Previous Next


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