[bsdgrep] grep -ql does not supress output

Doug Barton dougb at FreeBSD.org
Sat Jul 24 04:54:20 UTC 2010


On Fri, 23 Jul 2010, Doug Barton wrote:

> Thanks. I took another look at it, and I think the attached patch does the 
> trick,

Oops, forgot !Lflag in the last bit, this one fixes it.


Doug

-- 

 	Improve the effectiveness of your Internet presence with
 	a domain name makeover!    http://SupersetSolutions.com/

 	Computers are useless. They can only give you answers.
 			-- Pablo Picasso
-------------- next part --------------
Index: grep.c
===================================================================
--- grep.c	(revision 210438)
+++ grep.c	(working copy)
@@ -466,11 +466,11 @@
 			break;
 		case 'L':
 			lflag = false;
-			Lflag = qflag = true;
+			Lflag = true;
 			break;
 		case 'l':
 			Lflag = false;
-			lflag = qflag = true;
+			lflag = true;
 			break;
 		case 'm':
 			mflag = true;
Index: util.c
===================================================================
--- util.c	(revision 210438)
+++ util.c	(working copy)
@@ -226,9 +226,9 @@
 			printf("%s:", ln.file);
 		printf("%u\n", c);
 	}
-	if (lflag && c != 0)
+	if (lflag && !qflag && c != 0)
 		printf("%s\n", fn);
-	if (Lflag && c == 0)
+	if (Lflag && !qflag && c == 0)
 		printf("%s\n", fn);
 	if (c && !cflag && !lflag && !Lflag &&
 	    binbehave == BINFILE_BIN && f->binary && !qflag)
@@ -342,7 +342,7 @@
 		return (c); /* Binary file */
 
 	/* Dealing with the context */
-	if ((tail || c) && !cflag && !qflag) {
+	if ((tail || c) && !cflag && !qflag && !lflag && !Lflag) {
 		if (c) {
 			if (!first && !prev && !tail && Aflag)
 				printf("--\n");


More information about the freebsd-current mailing list