the_silver_searcher
the_silver_searcher copied to clipboard
Max count (--max-count) not working like expected in pipeline
I'm trying to get ag to stop at the first match because I don't care about the loopback address in ifconfig. But for some reason it seems to be searching the piped output twice:
ifconfig | ag --max-count 1 'inet '
ERR: Too many matches in . Skipping the rest of this file.
inet 10.0.4.111 netmask 255.255.0.0 broadcast 10.0.255.255
ERR: Too many matches in . Skipping the rest of this file.
inet 127.0.0.1 netmask 255.0.0.0
Is there some parallelization causing ag to read from the pipeline multiple times? What's going on here? It's not what I'd expect and it's not how grep
works:
ifconfig | grep -m 1 'inet '
inet 10.0.4.111 netmask 255.255.0.0 broadcast 10.0.255.255
Version:
ag version 2.2.0
Features:
+jit +lzma +zlib
@optik-aper did you ever figure this out by any chance? I just run into the same issue:
ag --nonumbers 1596042841 somelogs.log -m1
ERR: Too many matches in somelogs.log. Skipping the rest of this file.
### TIMESTAMP: 1596042841 - 1/2880 - pidstat duration: 30 ###
grep is happy though:
grep 1596042841 somelogs.log -m1
### TIMESTAMP: 1596042841 - 1/2880 - pidstat duration: 30 ###
EDIT: looks like it's the same as this? https://github.com/ggreer/the_silver_searcher/issues/483
also stumbled on this, definitely a bug.
Trivial test case:
❯ echo "a\na" | ag -m1 a
ERR: Too many matches in . Skipping the rest of this file.
a
ERR: Too many matches in . Skipping the rest of this file.
a
❯ echo "a\na" | grep -m1 a
a
Adding -F
and/or -s
doesn't help.
Environment: macOS Catalina, ag installed from homebrew.
No updates since version 2.2.0 release almost 3 years ago and over 300 issues. This is very sad but it seems this project has been abandoned. I love ag
and use it far more than any other search tool, even though I have several installed. Are there any known active forks?