diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-07-31 23:18:49 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-07-31 23:18:49 +0000 |
commit | 035a6d831571fa8b1d2c4b98ce5712b410d319e6 (patch) | |
tree | 168e32bc0921e40feb47f26326b50f4885b05131 /findutils/grep.c | |
parent | e180b83a0ec7c7fa6192af9ea08754f0e7b6c187 (diff) | |
download | busybox-w32-035a6d831571fa8b1d2c4b98ce5712b410d319e6.tar.gz busybox-w32-035a6d831571fa8b1d2c4b98ce5712b410d319e6.tar.bz2 busybox-w32-035a6d831571fa8b1d2c4b98ce5712b410d319e6.zip |
Fix behavior of grep -lc to match GNU grep. SuS2 is ambiguous
on the correct behavior, so acting like GNU grep seems best
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@3176 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'findutils/grep.c')
-rw-r--r-- | findutils/grep.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index 03cc9f836..3254868be 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -179,7 +179,10 @@ static void grep_file(FILE *file) | |||
179 | if (print_match_counts) { | 179 | if (print_match_counts) { |
180 | if (print_filename) | 180 | if (print_filename) |
181 | printf("%s:", cur_file); | 181 | printf("%s:", cur_file); |
182 | printf("%d\n", nmatches); | 182 | if (print_files_with_matches && nmatches > 0) |
183 | printf("1\n"); | ||
184 | else | ||
185 | printf("%d\n", nmatches); | ||
183 | } | 186 | } |
184 | 187 | ||
185 | /* grep -l: print just the filename, but only if we grepped the line in the file */ | 188 | /* grep -l: print just the filename, but only if we grepped the line in the file */ |