Bug 144980

Summary: Bug in special character ^ matching with -o and -c
Product: [Fedora] Fedora Reporter: E. Choroba <choroba>
Component: grepAssignee: Tim Waugh <twaugh>
Status: CLOSED UPSTREAM QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 3   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-01-13 12:10:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description E. Choroba 2005-01-13 11:33:18 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3)
Gecko/20041020

Description of problem:
Grep does not recognise beginning of a line when using the "matching
part" switches. If the line really matches the given pattern, then
grep tries to match the pattern in the line with the last match
deleted (try the following line: 
 $ echo aa | grep -o ^a
Expected result is
 a
while grep gives
 a
 a
which is a bug. Similarly,
 $ echo ab | grep -o ^.
should return
 a
but returns
 a
 b


Version-Release number of selected component (if applicable):
grep-2.5.1-31.2

How reproducible:
Always

Steps to Reproduce:
1. Run grep -c or grep -o. Use the special character ^ in the regular
expression.
2. If there is a matching line that contains the pattern more than
once with no other characters between the matches, all the matches are
written out.

Additional info:

Comment 1 Tim Waugh 2005-01-13 11:52:23 UTC
This happens with pristine 2.5.1a as well.

Comment 2 Tim Waugh 2005-01-13 12:10:02 UTC
Reported upstream:
https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=11579