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

Submitter:  Tim Waugh <twaugh>
Submitted:  Thu 13 Jan 2005 12:09:30 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 2 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-11-10 charles_levert StatusNone Fixed
    Open/ClosedOpen Closed

Back to the top

Powered by Savane 3.13-3230.
Corresponding source code