From a2f69e548587b7079e0973146895774250c3406a Mon Sep 17 00:00:00 2001 From: Erik Andersen Date: Wed, 19 Jan 2000 04:30:37 +0000 Subject: [PATCH] Bug fix. grep wasn't printing file names they way it was supposed to. -Erik --- Changelog | 2 ++ findutils/grep.c | 9 ++++++--- grep.c | 9 ++++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Changelog b/Changelog index 453a69b00..96012ff04 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ 0.42 * Made tar creation support in busybox tar optional. + * Made grep and grep -h do the right thing wrt printing + the file name (it failed to print files names in many cases). -Erik Andersen diff --git a/findutils/grep.c b/findutils/grep.c index fdfc959af..287d9f80d 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -90,8 +90,8 @@ extern int grep_main (int argc, char **argv) char *cp; char *needle; char *fileName; - int tellName=FALSE; - int ignoreCase=FALSE; + int tellName=TRUE; + int ignoreCase=TRUE; int tellLine=FALSE; @@ -115,7 +115,7 @@ extern int grep_main (int argc, char **argv) break; case 'h': - tellName = TRUE; + tellName = FALSE; break; case 'n': @@ -137,6 +137,9 @@ extern int grep_main (int argc, char **argv) if (argc==0) { do_grep( stdin, needle, "stdin", FALSE, ignoreCase, tellLine); } else { + /* Never print the filename for just one file */ + if (argc==1) + tellName=FALSE; while (argc-- > 0) { fileName = *argv++; diff --git a/grep.c b/grep.c index fdfc959af..287d9f80d 100644 --- a/grep.c +++ b/grep.c @@ -90,8 +90,8 @@ extern int grep_main (int argc, char **argv) char *cp; char *needle; char *fileName; - int tellName=FALSE; - int ignoreCase=FALSE; + int tellName=TRUE; + int ignoreCase=TRUE; int tellLine=FALSE; @@ -115,7 +115,7 @@ extern int grep_main (int argc, char **argv) break; case 'h': - tellName = TRUE; + tellName = FALSE; break; case 'n': @@ -137,6 +137,9 @@ extern int grep_main (int argc, char **argv) if (argc==0) { do_grep( stdin, needle, "stdin", FALSE, ignoreCase, tellLine); } else { + /* Never print the filename for just one file */ + if (argc==1) + tellName=FALSE; while (argc-- > 0) { fileName = *argv++;