buggrep - Bugs: bug #12995, grep with --color and -i causes...

 
 

You are not allowed to post comments on this tracker with your current authentification level.

bug #12995: grep with --color and -i causes color match not to be displayed

Submitted by:  None
Submitted on:  Thu 05 May 2005 09:33:54 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

(Jump to the original submission Jump to the original submission)

Wed 17 Mar 2010 08:25:54 AM UTC, comment #9:

Thank you for the bug report. This bug has been fixed in the
development sources, which can be downloaded using git from
git://git.sv.gnu.org/grep.git

Paolo Bonzini <bonzini>
Mon 08 Mar 2010 08:53:25 AM UTC, comment #8:

Work-in-progress patch posted to mailing list.

Paolo Bonzini <bonzini>
Tue 22 Dec 2009 09:11:01 AM UTC, comment #7:

More testcases from bug 18666:

The following commands all colour the a's and A's in their output:

LC_ALL=en_GB.utf8 grep --color -i a file
LC_ALL=en_GB.utf8 grep --color -i A file
LC_ALL=en_GB grep --color -i a file
LC_ALL=C grep --color -i a file

But these two commands do not:

LC_ALL=en_GB grep --color -i A file
LC_ALL=C grep --color -i A file

The combination of option -i with an uppercase letter in the search pattern and a non-UTF8 locale makes colourisation fail.

(That is: with grep from CVS. With grep-2.5.1 it works fine.)

Paolo Bonzini <bonzini>
Mon 14 Dec 2009 09:14:05 PM UTC, comment #6:

Actually no, the test case in bug 27196 still fails:

$ echo abcDEF | ./grep --color -i C.E # highlighted
abcDEF
$ echo abcDEF | LANG=en_US.ASCII ./grep --color -i C.E # not highlighted
abcDEF

I'm leaving the two bugs open even though they are two facets of the same bug. It is fixed in F12's grep.

Paolo Bonzini <bonzini>
Mon 14 Dec 2009 09:09:34 PM UTC, comment #5:

Latest comment shows that it's closed.

Paolo Bonzini <bonzini>
Sun 14 Jan 2007 02:13:17 AM UTC, comment #4:

i agree that the -io bug is fixed in the debian unstable version and in the cvs version. :)

DEBIAN-UNSTABLE:

grep (2.5.1.ds2-6) unstable

unstable$ locale
LANG=pl_PL.ISO-8859-2
LANGUAGE=en_PL:en_US:en_GB:en
LC_CTYPE="pl_PL.ISO-8859-2"
LC_NUMERIC="pl_PL.ISO-8859-2"
LC_TIME="pl_PL.ISO-8859-2"
LC_COLLATE="pl_PL.ISO-8859-2"
LC_MONETARY="pl_PL.ISO-8859-2"
LC_MESSAGES="pl_PL.ISO-8859-2"
LC_PAPER="pl_PL.ISO-8859-2"
LC_NAME="pl_PL.ISO-8859-2"
LC_ADDRESS="pl_PL.ISO-8859-2"
LC_TELEPHONE="pl_PL.ISO-8859-2"
LC_MEASUREMENT="pl_PL.ISO-8859-2"
LC_IDENTIFICATION="pl_PL.ISO-8859-2"
LC_ALL=pl_PL.ISO-8859-2

unstable$ echo "a A a A" | grep -o a
a
a
unstable$ echo "a A a A" | grep -io a
a
A
a
A
unstable$ echo "a A a A" | grep -o "[aA]"
a
A
a
A
unstable$ echo "a A a A" | LC_ALL="en_US.utf8" grep -io a
a
A
a
A

CVS version: compiled from CVS and installed in $HOME.

unstable$ echo "a A a A" | ~/bin/grep -o a
a
a
unstable$ echo "a A a A" | ~/bin/grep -io a
a
A
a
A
unstable$ echo "a A a A" | ~/bin/grep -o "[aA]"
a
A
a
A
unstable$ echo "a A a A" | LC_ALL="en_US.utf8" ~/bin/grep -io a
a
A
a
A

Great to see the fast and accurate response - it's what i expect from GNU. :)

boud indymedia <boud>
Fri 12 Jan 2007 06:24:44 PM UTC, comment #3:

> CONCLUSION: The bug affects not only highlighting,
> but also the --only-matching option.


This seems to be fixed in CVS. At least, I cannot reproduce your results with grep from CVS, nor on Ubuntu Edgy, nor on a current Gentoo installation. Your Knoppix is somewhat old; please retry with a later version.

echo "a A a A" | grep -o a
echo "a A a A" | grep -io a
echo "a A a A" | grep -o "[aA]"
echo "a A a A" | LC_ALL="en_US.utf8" grep -io a

Only with an unpatched grep-2.5.1a can I reproduce the non-matching behaviour; but then also the setting of LC_ALL="en_US.utf8" does not mask the bug.

(In future: do not add to bugs that look similar, but create a new bug instead. Leave it to the maintainers to mark bugs as duplicates where necessary.)

Benno Schulenberg <bens>
Fri 12 Jan 2007 01:23:52 PM UTC, comment #2:

SUMMARY:
variant of bug #12995: --ignore-case fails with --only-matching option

SEVERITY: more important than as indicated by the initial bug report,
since this is not just about highlighting.

SYSTEM:
knoppix@2[knoppix]$ uname -a
Linux Knoppix 2.6.12 #2 SMP Tue Aug 9 23:20:52 CEST 2005 i686 GNU/Linux

PACKAGE VERSION:
grep --version
grep (GNU grep) 2.5.1

LOCALE:
knoppix@2[knoppix]$ locale
LANG=pl_PL
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C

EXAMPLE OF PROBLEM:

#This is OK
knoppix@2[knoppix]$ echo "a A a A" |grep --only-matching a
a
a

#This is wrong.
knoppix@2[knoppix]$ echo "a A a A" | \
grep --ignore-case --only-matching a
a
a

# This is OK.
knoppix@2[knoppix]$ echo "a A a A" |grep --only-matching "[aA]"
a
A
a
A

# Setting the locale corrects the bug, as described in #12995.
knoppix@2[knoppix]$ echo "a A a A" | \
LC_ALL="en_US.utf8" grep --ignore-case --only-matching a
a
A
a
A

CONCLUSION:
The bug affects not only highlighting, but also the --only-matching option.

boud indymedia <boud>
Thu 05 May 2005 11:23:13 PM UTC, comment #1:

Thanks for the report.

Unfortunately, this bug does exist in the latest stable release of GNU grep (2.5.1a).

The current CVS version is ok with LC_ALL="en_US.utf8" but still exhibits the bug with non-utf8 locales.

A version built by applying the current Red Hat/Fedora patches on top of 2.5.1a does not exhibit the problem. The patch which makes the difference is likely the "oi" one (patch #3807).

The bug does not occur with "grep -F".

Charles Levert <charles_levert>
Thu 05 May 2005 09:33:54 PM UTC, original submission:

This is my first time posting, so I hope no one has already posted this. I'm using grep 2.5 on windows XP.

When I run grep with the -i option the match color does not display. Please note that with or without the -i command, I always see the same grep output when my regexp is "someInst"...the problem here is the color highlight match.

The examples below show what happens:

grep --color=always -e "someInst" *.h

The output of this command has the highlighting.

grep -i --color=always -e "someInst" *.h

The output of this command does NOT have the highlighting.

I believe this is a bug.

Anonymous

 

No files currently attached

 

Digest:
   patch dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by pipping
  • -unavailable- added by bonzini (Posted a comment)
  • -unavailable- added by bens (Posted a comment)
  • -unavailable- added by boud (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 10 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 17 Mar 2010 08:25:54 AM UTCbonziniStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Mon 08 Mar 2010 08:53:25 AM UTCbonziniStatusConfirmed=>In Progress
    Mon 04 Jan 2010 07:49:01 PM UTCpippingCarbon-Copy-=>Added pipping
    Mon 14 Dec 2009 09:14:05 PM UTCbonziniOpen/ClosedClosed=>Open
      StatusFixed=>Confirmed
    Mon 14 Dec 2009 09:09:34 PM UTCbonziniOpen/ClosedOpen=>Closed
      StatusConfirmed=>Fixed
    Thu 05 May 2005 11:30:25 PM UTCcharles_levertDependencies-=>Depends on patch #3807
    Thu 05 May 2005 11:23:13 PM UTCcharles_levertStatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup