buggrep - Bugs: bug #25765, grep -P regexp also prints the...

 
 

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

bug #25765: grep -P regexp also prints the line before the match

Submitter:  Andriy Sen <apsen>
Submitted:  Wed 04 Mar 2009 07:01:05 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Fri 04 Dec 2009 07:28:08 PM UTC, comment #2: 

Duplicate of bug 17264.

Paolo Bonzini <bonzini>
Fri 04 Dec 2009 07:09:46 PM UTC, comment #1: 

Reproducible, matches can span multiple lines:

$ echo $'a\nb' | ./grep -P '^(|.*[^0])b'
a
b
$ echo $'a\nb' | ./grep -cP '^(|.*[^0])b'
1

Paolo Bonzini <bonzini>
Wed 04 Mar 2009 07:01:05 PM UTC, original submission:  


As far as I could see this is not the same as one of previously reported problems.

See tree examples below. The last one shows the problem.

G:\>grep -V
GNU grep 2.5.3

Copyright (C) 1988, 1992-2002, 2004, 2005  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


G:\>cat test.s
a
1

G:\>od -a test.s
0000000   a  nl   1  nl
0000004

G:\>cat test.s | grep -P "^[^0]1"


G:\>cat test.s | grep -P "^(|[^0])1"
1

G:\>cat test.s | grep -P "^(|.*[^0])1"
a
1

G:\>


Andriy Sen <apsen>

 

(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

 

Carbon-Copy List
  • -email is unavailable- added by bonzini (Posted a comment)
  • -email is unavailable- added by apsen (Submitted the item)
  •  

    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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-12-04 bonzini Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code