bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug in gnu grep -o


From: David Emerson
Subject: bug in gnu grep -o
Date: Thu, 7 Sep 2006 12:30:06 -0700
User-agent: KMail/1.7.2

$ echo foobar | grep -o '^.'
f
o
o
b
a
r

There is a beginning-of-line anchor '^' so grep should only match 'f', 
not the rest.

$ grep --version
grep (GNU grep) 2.5.1


A few other test cases:

$ echo foobar | grep -o '^[fb]'  # this one works properly
f
$ echo foobar | grep -o '^[fb]..'  # this one is broken
foo
bar
$ echo foobar | grep -o '^[fb].'  # but this works properly!
fo

I (being a black box sort of tester) am going to guess that, after 
matching the pattern, grep -o *deletes* the beginning of the string, or 
moves the pointer, or something ... so that grep -o can continue doing 
its magic ... but then it is able to match at the beginning of the 
string again.

End-of-line anchors seem to work properly.

~David.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]