NetBSD Problem Report #40080
From www@NetBSD.org Tue Dec 2 12:28:57 2008
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id EDF5F63BD2D
for <gnats-bugs@gnats.netbsd.org>; Tue, 2 Dec 2008 12:28:56 +0000 (UTC)
Message-Id: <20081202122856.ADAD363B8BD@narn.NetBSD.org>
Date: Tue, 2 Dec 2008 12:28:56 +0000 (UTC)
From: track.NetBSD@mylists.org
Reply-To: track.NetBSD@mylists.org
To: gnats-bugs@NetBSD.org
Subject: grep's --color switch won't work with -i option
X-Send-Pr-Version: www-1.0
>Number: 40080
>Category: bin
>Synopsis: grep's --color switch won't work with -i option
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Dec 02 12:30:00 +0000 2008
>Last-Modified: Thu Jan 19 18:00:01 +0000 2017
>Originator: Dallman Ross
>Release: 4.0, 5.0_BETA
>Organization:
>Environment:
NetBSD panix5.panix.com 5.0_BETA NetBSD 5.0_BETA (PANIX-XEN3U-USER) #0: Wed Nov 12 09:29:45 EST 2008 root@juggler.panix.com:/misc1/obj/misc2/devel/netbsd/5-beta/src/sys/arch/i386/compile/PANIX-XEN3U-USER i386
>Description:
The --color switch to grep won't work in concert with the -i option if the arg to the -i option is upper-case.
>How-To-Repeat:
Try these two examples:
$ echo Dogfood | grep -i --color dog
and:
$ echo Dogfood | grep -i --color Dog
They both print "Dogfood" for me under both NetBSD 4.0 and 5.0_BETA, but only the first one (using lower case "dog" as the pattern match) shows the
color. So it looks like this will work as long as you specify the pattern in lower case.
>Fix:
>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/40080: grep's --color switch won't work with -i option
Date: Thu, 19 Jan 2017 17:56:31 +0000
On Tue, Dec 02, 2008 at 12:30:01PM +0000, track.NetBSD@mylists.org wrote:
> The --color switch to grep won't work in concert with the -i option
> if the arg to the -i option is upper-case.
> >How-To-Repeat:
> Try these two examples:
>
> $ echo Dogfood | grep -i --color dog
>
> and:
>
> $ echo Dogfood | grep -i --color Dog
>
> They both print "Dogfood" for me under both NetBSD 4.0 and
> 5.0_BETA, but only the first one (using lower case "dog" as the
> pattern match) shows the color.
(1) This also affects grep -o, except without the "lowercase is magic"
effect:
valkyrie% echo Dogfood | grep -i -o dog
valkyrie% echo Dogfood | grep -i -o Dog
Dog
This is because the "logic" in grep.c for identifying the matching
part is cutpasted, but only the --color copy includes logic for -i.
(2) The underlying problem is that for some weird broken gnu code
reason, when it calls back into the matching engine to identify the
matching part, the matching engine no longer honors -i.
(3) Instead of fixing this, at some point someone introduced a bodge
into the --color copy of the matching-part code that operates on a
lowercased version of the matched line when -i is in effect. This
means that -i --color works as long as the search pattern is
lowercase, but not otherwise, as observed, whereas -i -o works as if
-i had been left off.
(4) This crap now lives in external/gpl2/grep/dist/src/grep.c.
--
David A. Holland
dholland@netbsd.org
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.