Skip to content

Commit

Permalink
grep: fix combination of quite and count flag
Browse files Browse the repository at this point in the history
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
  • Loading branch information
oshogbo committed Jul 9, 2021
1 parent 84992a3 commit 24c681a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion usr.bin/grep/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 24c681a

Please sign in to comment.