Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jul 2021 12:10:17 GMT
From:      Mariusz Zaborski <oshogbo@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 24c681a7f6d6 - main - grep: fix combination of quite and count flag
Message-ID:  <202107091210.169CAHVx063934@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by oshogbo:

URL: https://cgit.FreeBSD.org/src/commit/?id=24c681a7f6d6c777221fdbd289da64ff65ad8785

commit 24c681a7f6d6c777221fdbd289da64ff65ad8785
Author:     Mariusz Zaborski <oshogbo@FreeBSD.org>
AuthorDate: 2021-07-09 12:09:14 +0000
Commit:     Mariusz Zaborski <oshogbo@FreeBSD.org>
CommitDate: 2021-07-09 12:09:14 +0000

    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
---
 usr.bin/grep/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index a2520e24de8e..698e347c192e 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107091210.169CAHVx063934>