From df7a3bfc7fe30f3e9e89d8775748b1239c5b5fc4 Mon Sep 17 00:00:00 2001 From: Wieland Hoffmann Date: Fri, 10 Apr 2020 11:19:25 +0200 Subject: [PATCH] grep-cli: support files compressed by compress(1) While Linux distributions (at least Arch Linux, RHEL, Debian) do not support compressing files with compress(1), macOS & AIX do (the utility is part of POSIX). Additionally, gzip is able to uncompress such compressed files and provides an `uncompress` binary. Closes #1547 --- CHANGELOG.md | 5 +++++ crates/cli/src/decompress.rs | 2 ++ crates/ignore/src/default_types.rs | 1 + tests/data/sherlock.Z | Bin 0 -> 286 bytes tests/misc.rs | 15 +++++++++++++++ 5 files changed, 23 insertions(+) create mode 100644 tests/data/sherlock.Z diff --git a/CHANGELOG.md b/CHANGELOG.md index bd860458..5c22be35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ TBD === +Feature enhancements: + +* [FEATURE #1547](https://github.com/BurntSushi/ripgrep/pull/1547): + Support decompressing `.Z` files via `uncompress`. + Bug fixes: * [BUG #1252](https://github.com/BurntSushi/ripgrep/issues/1252): diff --git a/crates/cli/src/decompress.rs b/crates/cli/src/decompress.rs index c2b2738b..94e118b1 100644 --- a/crates/cli/src/decompress.rs +++ b/crates/cli/src/decompress.rs @@ -348,6 +348,7 @@ fn default_decompression_commands() -> Vec { const ARGS_LZMA: &[&str] = &["xz", "--format=lzma", "-d", "-c"]; const ARGS_BROTLI: &[&str] = &["brotli", "-d", "-c"]; const ARGS_ZSTD: &[&str] = &["zstd", "-q", "-d", "-c"]; + const ARGS_UNCOMPRESS: &[&str] = &["uncompress", "-c"]; fn cmd(glob: &str, args: &[&str]) -> DecompressionCommand { DecompressionCommand { @@ -372,5 +373,6 @@ fn default_decompression_commands() -> Vec { cmd("*.br", ARGS_BROTLI), cmd("*.zst", ARGS_ZSTD), cmd("*.zstd", ARGS_ZSTD), + cmd("*.Z", ARGS_UNCOMPRESS), ] } diff --git a/crates/ignore/src/default_types.rs b/crates/ignore/src/default_types.rs index 9136647a..fa83b3d7 100644 --- a/crates/ignore/src/default_types.rs +++ b/crates/ignore/src/default_types.rs @@ -234,6 +234,7 @@ pub const DEFAULT_TYPES: &[(&str, &[&str])] = &[ ("xz", &["*.xz", "*.txz"]), ("yacc", &["*.y"]), ("yaml", &["*.yaml", "*.yml"]), + ("z", &["*.Z"]), ("zig", &["*.zig"]), ("zsh", &[ ".zshenv", "zshenv", diff --git a/tests/data/sherlock.Z b/tests/data/sherlock.Z new file mode 100644 index 0000000000000000000000000000000000000000..9ffa9283ad25673bd23820c9685ced10c94d8dfe GIT binary patch literal 286 zcmV+(0pb21osdS}$N@nIO&JhG-i)Cm5X6-*bmqKqGY7;QGX&A3sdz^q8!{|FgsJ!j z4xBf0%8()WCgZ^=2Ia6(xJChzH*DIJNjWFvoH}F1?5vo^jY|-4