On Sat, 24 Jul 2010, Gabor Kovesdan wrote:

Em 2010.07.24. 6:19, Doug Barton escreveu:
There are several places in portmaster where I use '[e]grep -ql <foo>' to signal existence of something without having to deal with the output of grep. In oldgrep this worked as advertised. In bsdgrep it doesn't.

Furthermore, looking at the code it doesn't seem like it's a trivial fix since you seem to be conflating the idea of -q with "don't output the matching lines" instead of "don't output anything" which is what the old one did:

                case 'l':
                        Lflag = false;
                        lflag = qflag = true;
                        break;

Also, looking at the code it's not clear to me that the -q option has its previous behavior of halting processing for that file on the first match, but I've only given it a quick look.

So, request number 1, fix it so that bsdgrep -ql doesn't output anything, and make sure that -q actually halts processing on the first match.

Of course both this and the color issue will be fixed.

Thanks. I took another look at it, and I think the attached patch does the trick, although you'll probably want to regression test it. I'm running some limited tests now as well. I still haven't verified that -q halts processing on the first match however.

Request number 2, think about whether or not introducing this as the default was the right course of action. I held my tongue on this when you committed it, but in the past when such things have been added they start life as an option, allowing those who choose to do so to regression test them. Once they've had a shakeout period THEN the switch is flipped to make them the default. I'm not at the point yet where I'm ready to ask for you to change this, but between the color thing and this issue, that ball has started to roll, in my mind at least. We'll see what happens with more testing.

This change was thoroughly tested on pointyhat and by several interested people even by you. Actually, the compatibility for non-standard GNU regexes were added when you requested it after trying out with portmaster.

Yes, IIRC that was when I last tested it for you about 2 years ago. And I appreciate you adding that support.

Why didn't you tell me earlier about this bug then, as well?

My fuzzy recollection is that the various micro-optimizations such as this one have been added to portmaster in the intervening 2 years, but I could be wrong. If the bug and my code were both there 2 years ago, please accept my apologies for not reporting it sooner.

Meanwhile, pointyhat runs are great for trying to assess bare technical compatibility with known combinations of options; however as I've learned in trying to regression-test portmaster, real human users are roughly infinitely more creative than that. :)


hth,

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
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) {
                if (c) {
                        if (!first && !prev && !tail && Aflag)
                                printf("--\n");
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[email protected]"

Reply via email to