buggrep - Bugs: bug #11579, "echo ab | grep -o ^."...

 
 

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

bug #11579: "echo ab | grep -o ^." gives incorrect output

Submitted by:  Tim Waugh <twaugh>
Submitted on:  Thu 13 Jan 2005 12:09:30 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Thu 10 Nov 2005 08:15:19 PM UTC, comment #2:

This issue has been addressed by patch #4604.

Charles Levert <charles_levert>
Sat 25 Jun 2005 04:50:43 AM UTC, comment #1:

This bug also applies to other anchors (\<,\>,\b, etc.)
echo A llittle problem | grep -o "\<l"
responds with two matches instead of one.
Also,
echo A llittle problem | grep --color "\<l"
colors both l's in llittle, when it should only color the first one.

I suspect, though I have not looked at the code, that since grep was originally designed to show the entire line of input if any part of the line matches the expression, it originally stopped searching for a pattern after the first match. When the -o (and later the related --color) option was added, to be able to show all the matches on a line, the regular expression search was restarted on the line at the point of the last match as though it was the beginning of the line. Hence,
echo This is a liittle problem | grep -E --color "(\<l)|(^i)"
colors the lii in liitle.

Anonymous
Thu 13 Jan 2005 12:09:30 PM UTC, original submission:

When using a beginning-of-line anchor in a pattern, several matches per line may be displayed. Of course there can only be one legal match per line in that case.

Original bug report:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=144980

Tim Waugh <twaugh>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

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 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 10 Nov 2005 08:15:19 PM UTCcharles_levertStatusNone=>Fixed
  Open/ClosedOpen=>Closed

Back to the top


Powered by Savane 3.1-cleanup1