grep: fix combination of quite and count flag

When the quite (-q) flag is provided, we don't expect any output.
Currently, the behavior is broken:
$ grep -cq flag util.c
1

$ grep -cs flag util.c
55

First of all, we print a number to stdout. Secondly, it just returns
0 or 1 (which is unexpected). GNU grep with c and q flags doesn't
print anything.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D31108
This commit is contained in:
Mariusz Zaborski 2021-07-09 14:09:14 +02:00
parent 84992a3251
commit 24c681a7f6

View File

@ -388,7 +388,7 @@ procfile(const char *fn)
clearqueue();
grep_close(f);
if (cflag) {
if (cflag && !qflag) {
if (!hflag)
printf("%s:", pc.ln.file);
printf("%u\n", lines);