[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#23991: closed (-H if nfiles>1: effect on find -exe

From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#23991: closed (-H if nfiles>1: effect on find -exec/-execdir grep)
Date: Fri, 15 Jul 2016 09:46:02 +0000

Your message dated Fri, 15 Jul 2016 11:44:46 +0200
with message-id <address@hidden>
and subject line Re: bug#23991: -H if nfiles>1: effect on find -exec/-execdir 
has caused the debbugs.gnu.org bug report #23991,
regarding -H if nfiles>1: effect on find -exec/-execdir grep
to be marked as done.

(If you believe you have received this mail in error, please contact

23991: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23991
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: -H if nfiles>1: effect on find -exec/-execdir grep Date: Fri, 15 Jul 2016 18:30:28 +0900 (JST) User-agent: Alpine 2.20 (DEB 67 2015-01-07)

Printing file names with grep by default when grep receives nfiles>1
may produce output with and without file names (when called via find).

* Edit the attached shell script:
  (Set the var 'dir' with the location of the local grep repository).
* Run the script.
* Read the comments inside the script and check the output.


From c054df7838d54808ab751e8f4fc38f373a968c67 Mon Sep 17 00:00:00 2001
From: Tino Calancha <address@hidden>
Date: Fri, 15 Jul 2016 17:31:07 +0900
Subject: [PATCH] Do not print file names by default when nfiles >1

* src/grep.c (main): Print file names only when command contains
the option --with-filename (or -H).
* doc/grep.texi (-H, --with-filename): Update documenation.
 doc/grep.texi | 1 -
 src/grep.c    | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/doc/grep.texi b/doc/grep.texi
index 80768dd..09e7347 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -419,7 +419,6 @@ see below.
 @opindex --with-filename
 @cindex with filename prefix
 Print the file name for each match.
-This is the default when there is more than one file to search.

 @item -h
 @itemx --no-filename
diff --git a/src/grep.c b/src/grep.c
index 302e4d7..242253f 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2681,7 +2681,7 @@ main (int argc, char **argv)
   skip_empty_lines = ((execute (eolbytes + 1, 1, &match_size, NULL) == 0)
                       == out_invert);

-  if ((argc - optind > 1 && !no_filenames) || with_filenames)
+  if (with_filenames)
     out_file = 1;

 #ifdef SET_BINARY

Attachment: grep_find.sh
Description: Bourne shell script

--- End Message ---
--- Begin Message --- Subject: Re: bug#23991: -H if nfiles>1: effect on find -exec/-execdir grep Date: Fri, 15 Jul 2016 11:44:46 +0200 User-agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 This is not a bug, as grep has behaved that way for decades, this behavior is standardized by POSIX, and changing the behavior would cause more trouble than it would cure. To get the behavior you want, use 'grep -H' or 'grep ... /dev/null' as discussed in the grep manual (see node Usage).

--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]