svent / sift

A fast and powerful alternative to grep
https://sift-tool.org
GNU General Public License v3.0
1.6k stars 108 forks source link

Not only .gz can be a gzipped file #63

Closed tgulacsi closed 8 years ago

tgulacsi commented 8 years ago

Check the magic first 3 bytes to decide wether to decompress or not.

I use runit's svlogd, and compress the logs with gzip. The resulting file names have a ".s" extension, not ".gz", so sift does not decompress them and skips them.

This PR checks the files' first 3 bytes (as gzip.readHeader) to decide whether the file is gzip-compressed or not.

svent commented 8 years ago

Thanks for your suggestion. I think this is good idea, but I would like to add this as a special option (to detect zipped files by looking at the content) instead of changing the behavior of the existing --zip option (as this does have a performance impact, changes existing behavior and can lead to errors with binary files). It would also be nice to support more file types.

I will create an issue for this and implement it in a future version.