bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch: non-empty matches following empty ones


From: Stepan Kasal
Subject: Re: Patch: non-empty matches following empty ones
Date: Tue, 23 Aug 2005 16:24:05 +0200
User-agent: Mutt/1.4.1i

Hi,

On Tue, Aug 23, 2005 at 07:09:20AM -0400, Charles Levert wrote:
> You've been MIA (missing in action) for a while
> on this list!   :-)
> Good to read you back.

Sorry.  I'll try to do better.

> Do you realize that for such patterns:
> 
>    -- every line matches;
> 
>    -- every place on a line where there isn't
>       already a non-empty match, there will be
>       an empty match between any two adjacent
>       characters;
> 
>    -- with --only-matching, that will just
>       produce a _lot_ of "filename:\n" lines;
> 
>    -- with --color, this will just produce a _lot_
>       of human-invisible "\33[01;31m\33[K\33[m\33[K"
>       pairs, along with possibly more such
>       stuff around each non-matching character
>       if GREP_COLORS is so configured (and the
>       concern below addressed).

Sure, I understood that.  That's what
        sed 's/a*/X/g'
or
        awk 'gsub(/a*/,"X")'
does.

Your arguments seem to show that grep should print only lines
with _nonempty_ matches.  (Empty pattern might be an exception.)
But that's too late to change.

With current setup, the inconsistency will show up because
        grep --colour 'a*'
will then print lot of lines without any colour tags.
It might be confusing for X-ray robots who expects to see the
tags...

I wanted to prefer consistency.  Then I'd have to teach people that they
shouldn't use patterns which match empty string.

You wanted to change the specification of --only-matching (--colour),
so that it prints (colorifies) only non-empty matches.

OK, I no longer object to it.  But please change the decumentation
(info and manpage) so that it states this clearly.

Have a nice day,
        Stepan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]