Open skrattaren opened 9 years ago
This is yet another side effect of ag not reading line-by-line. Because it looks at the entire text as a single buffer, it's seeing \n\n\nnothing here\nt.test()
, which matches your regex. I don't really think there's a good way to work around that, but someone else may know more.
This issue pops up periodically. Here's a solution:
$ ag '^[^=\n]+test' test.file
3:t.test()
6:t.test()
$
Here's a proposed man page change that documents same.
Thanks, @decaff (esp. for the workaround) and @epmatsw, hadn't realized this is an issue with multiline buffer, otherwise I've found earlier issues Should I close this issue as duplicate of #459, then?
Let's take the file
I want to find all the invocations of method
test()
where result isn't assigned. So I use the following regexp:Why do all those lines match? Both
ack
andegrep
produce correct result:Mac OS X Mavericks: