ggreer / the_silver_searcher

A code-searching tool similar to ack, but faster.
http://geoff.greer.fm/ag/
Apache License 2.0
26.05k stars 1.42k forks source link

-z option in version 2.2.0 returns no result #1348

Open TomonoriSoejima opened 4 years ago

TomonoriSoejima commented 4 years ago

I encountered the problem with -z option not being able to match anything when I installed ag on my new MacBook Pro.

Here you can see it is working with the older version.

[mbp:logs]$ uname -a 
Darwin mbp.local 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64 i386 MacBookPro13,3 Darwin
[mbp:logs]$ ag --version
ag version 1.0.2

Features:
  +jit +lzma +zlib
[mbp:logs]$ ag -z adding ./00460893/logstash-plain.log.gz | head -4
2:[2019-11-27T15:28:42,628][DEBUG][logstash.util.decorators ] filters/LogStash::Filters::Grok: adding tag {"tag"=>"1501"}
12:[2019-11-27T15:28:42,628][DEBUG][logstash.util.decorators ] filters/LogStash::Filters::Mutate: adding value to field {"field"=>"date_tmp", "value"=>["%{date_str} %{+YYYY}"]}
20:[2019-11-27T15:28:42,628][DEBUG][logstash.util.decorators ] filters/LogStash::Filters::Mutate: adding value to field {"field"=>"date_tmp", "value"=>["%{date_str} %{+YYYY}"]}
64:[2019-11-27T15:28:42,634][DEBUG][logstash.util.decorators ] filters/LogStash::Filters::Mutate: adding value to field {"field"=>"date_tmp", "value"=>["%{date_str} %{+YYYY}"]}
[mbp:logs]$ 

In version 2.2.0

[nami:logs]$ ag --version
ag version 2.2.0

Features:
  +jit +lzma +zlib
[nami:logs]$ uname -a
Darwin nami.local 19.0.0 Darwin Kernel Version 19.0.0: Wed Oct 23 18:29:05 PDT 2019; root:xnu-6153.41.3~44/RELEASE_X86_64 x86_64
[nami:logs]$ ag --version
ag version 2.2.0

Features:
  +jit +lzma +zlib
[nami:logs]$ ag -z adding ./00460893/logstash-plain.log.gz
[nami:logs]$ 
jialeicui commented 4 years ago

try with --search-binary option?

timcharper commented 4 years ago

Came here to say the same; this option used to work fine but it's changed in 2.2.0. --search-binary seems to be a suddenly requisite for using -z.

$ echo "The quick brown fox" | tee data.txt | gzip > data.txt.gz

$ ag "quick"
data.txt
1:The quick brown fox

$ ag -z "quick"
data.txt
1:The quick brown fox

$ ag --search-binary -z "quick"
data.txt
1:The quick brown fox

data.txt.gz
1:The quick brown fox

$