Bug 125325

Summary: Annoying grep(1) bug with --color
Product: Base System Reporter: Ighighi <ighighi>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 6.3-STABLE   
Hardware: Any   
OS: Any   

Description Ighighi 2008-07-06 06:00:02 UTC
GNU grep(1) -color has an annoying bug. Sometimes it doesn't colorize the relevant
string.

Old-school tty hackers: I value my vision ;-)

Fix: 

GNU grep fixed it some time ago.
How-To-Repeat: $ env -i /usr/bin/grep --colour=always :0: /etc/passwd
root:*:0:0:Charlie &:/root:/usr/local/bin/bash
toor:*:0:0:Bourne-again Superuser:/root:

The entire ":0:0:" should be colorized.
Comment 1 Kris Kennaway freebsd_committer freebsd_triage 2008-07-06 19:18:26 UTC
Ighighi wrote:

> GNU grep fixed it some time ago

Which version contains the fix?

Kris
Comment 2 Wayne Sierke 2008-07-07 18:59:16 UTC
On Sun, 2008-07-06 at 04:50 +0000, Ighighi wrote:
> 
> $ env -i /usr/bin/grep --colour=always :0: /etc/passwd
> root:*:0:0:Charlie &:/root:/usr/local/bin/bash
> toor:*:0:0:Bourne-again Superuser:/root:
> 
> The entire ":0:0:" should be colorized.

Note that this is probably to do with pattern-matching rather than
colouring:

        %env -i /usr/bin/grep --only-matching :0: /etc/passwd
        :0:
        :0:
        %/usr/bin/grep --version
        grep (GNU grep) 2.5.1-FreeBSD
        
        ...
        

Testing with ubuntu-8.04.1:
        
        ws@ubuntu:~$ env -i /bin/grep --colour=always :0: /etc/passwd
        root:x:0:0:root:/root:/bin/bash
        ws@ubuntu:~$ env -i /bin/grep --only-matching :0: /etc/passwd
        :0:
        ws@ubuntu:~$ /bin/grep --version
        GNU grep 2.5.3
        
        ...


(only the first :0: is coloured in the first result). 

2.5.3 seems to be the latest version of GNU grep.

It's not clear that failing to match overlapped instances of patterns is
a bug.
Comment 3 Volker Werth freebsd_committer freebsd_triage 2010-08-28 19:43:51 UTC
State Changed
From-To: open->closed

I agree with Wayne, who suggested the overlapped matching. 
As we don't have any patches, we're closing this PR. Will be happy to open up again if we receive patches.
Comment 4 Alexander Best freebsd_committer freebsd_triage 2010-08-29 10:51:22 UTC
it would be interesting to see how the new BSD licensed grep handles this case.

-- 
a13x
Comment 5 Alexander Best freebsd_committer freebsd_triage 2010-08-29 11:07:16 UTC
ok just checked. GNU grep and BSD grep behave exactly the same in this case. :)

cheers.
alex

-- 
a13x