Closed dmcbride closed 7 years ago
I believe that this may already have a ticket.
And if I remember correctly, it is counting the heading line for the file in the line count.
$ echo -e "abcdgh\nabcegh" | ack -c 'ab(c(d|e)|ef)gh' - | cat
-:4
Two lines matching come out as four, so I'm not sure about counting a "heading line" - it really looks to be doubled.
I did try looking for an existing ticket, so my apologies if I missed it.
It seems as if the amount of nested parentheses is relevant:
→ echo "abcdgh" | ack -c 'abc((d))gh'
2
→ echo "abcdgh" | ack -c 'abc(((d)))gh'
3
It doesn't matter whether the groups are nested or not.
$ echo "abcdgh" | ack -c 'abc(d)(g)h'
2
Simpler patterns also count many times.
$ echo -e "aa" | ack -c 'a'
2
@fluks @dmcbride Can you tell me what versions of ack you're using? I can't get reproduce this behavior with ack 2.18.
@petdance I opened this nearly two years ago, you expect me to remember what version that was? :D I believe it should have been my system ack at the time, so looking through my records, it looks like that would have been 2.14.
I cannot reproduce with 2.18, either, which is the level I have now. I can try downgrading my ack to 2.14 if you'd like, though it would appear that 03dee1f seems like a legitimate fix for this problem.
Note that the original functionality, count the number of matches, may also be a useful number to extract, but not under a flag that says "Show number of lines matching per file" :)
It fails under 2.14 (There's a 2.14 in the garage/
directory of ack2) but happens no longer for me, either. So I'm going to close this since you seem satisfied with this, too. Thanks for getting back to me.
As to the flags that don't make sense together, there's a big bunch of mutex options in @INVALID_COMBINATIONS
in lib/App/Ack/ConfigLoader.pm that we keep adding to. It's getting overhauled in ack3.
(I have a pager set, so the |cat is just to avoid the pager, ignore the useless use of cat) This is a vastly vastly simplified version of my original problem, which is one where
[chars]
would not work.Hmm - how does a one line file have two lines matching? Odd, too, because only one branch actually should match.