[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23991: -H if nfiles>1: effect on find -exec/-execdir grep
From: |
Tino Calancha |
Subject: |
bug#23991: -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
--
2.8.1
grep_find.sh
Description: Bourne shell script
- bug#23991: -H if nfiles>1: effect on find -exec/-execdir grep,
Tino Calancha <=