mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-19 09:40:22 -07:00
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
This commit is contained in:
parent
28f2a93cae
commit
df7a3bfc7f
@ -1,5 +1,10 @@
|
|||||||
TBD
|
TBD
|
||||||
===
|
===
|
||||||
|
Feature enhancements:
|
||||||
|
|
||||||
|
* [FEATURE #1547](https://github.com/BurntSushi/ripgrep/pull/1547):
|
||||||
|
Support decompressing `.Z` files via `uncompress`.
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
* [BUG #1252](https://github.com/BurntSushi/ripgrep/issues/1252):
|
* [BUG #1252](https://github.com/BurntSushi/ripgrep/issues/1252):
|
||||||
|
@ -348,6 +348,7 @@ fn default_decompression_commands() -> Vec<DecompressionCommand> {
|
|||||||
const ARGS_LZMA: &[&str] = &["xz", "--format=lzma", "-d", "-c"];
|
const ARGS_LZMA: &[&str] = &["xz", "--format=lzma", "-d", "-c"];
|
||||||
const ARGS_BROTLI: &[&str] = &["brotli", "-d", "-c"];
|
const ARGS_BROTLI: &[&str] = &["brotli", "-d", "-c"];
|
||||||
const ARGS_ZSTD: &[&str] = &["zstd", "-q", "-d", "-c"];
|
const ARGS_ZSTD: &[&str] = &["zstd", "-q", "-d", "-c"];
|
||||||
|
const ARGS_UNCOMPRESS: &[&str] = &["uncompress", "-c"];
|
||||||
|
|
||||||
fn cmd(glob: &str, args: &[&str]) -> DecompressionCommand {
|
fn cmd(glob: &str, args: &[&str]) -> DecompressionCommand {
|
||||||
DecompressionCommand {
|
DecompressionCommand {
|
||||||
@ -372,5 +373,6 @@ fn default_decompression_commands() -> Vec<DecompressionCommand> {
|
|||||||
cmd("*.br", ARGS_BROTLI),
|
cmd("*.br", ARGS_BROTLI),
|
||||||
cmd("*.zst", ARGS_ZSTD),
|
cmd("*.zst", ARGS_ZSTD),
|
||||||
cmd("*.zstd", ARGS_ZSTD),
|
cmd("*.zstd", ARGS_ZSTD),
|
||||||
|
cmd("*.Z", ARGS_UNCOMPRESS),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -234,6 +234,7 @@ pub const DEFAULT_TYPES: &[(&str, &[&str])] = &[
|
|||||||
("xz", &["*.xz", "*.txz"]),
|
("xz", &["*.xz", "*.txz"]),
|
||||||
("yacc", &["*.y"]),
|
("yacc", &["*.y"]),
|
||||||
("yaml", &["*.yaml", "*.yml"]),
|
("yaml", &["*.yaml", "*.yml"]),
|
||||||
|
("z", &["*.Z"]),
|
||||||
("zig", &["*.zig"]),
|
("zig", &["*.zig"]),
|
||||||
("zsh", &[
|
("zsh", &[
|
||||||
".zshenv", "zshenv",
|
".zshenv", "zshenv",
|
||||||
|
BIN
tests/data/sherlock.Z
Normal file
BIN
tests/data/sherlock.Z
Normal file
Binary file not shown.
@ -970,6 +970,21 @@ be, to a very large extent, the result of luck. Sherlock Holmes
|
|||||||
eqnice!(expected, cmd.stdout());
|
eqnice!(expected, cmd.stdout());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rgtest!(compressed_uncompress, |dir: Dir, mut cmd: TestCommand| {
|
||||||
|
if !cmd_exists("uncompress") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dir.create_bytes("sherlock.Z", include_bytes!("./data/sherlock.Z"));
|
||||||
|
cmd.arg("-z").arg("Sherlock").arg("sherlock.Z");
|
||||||
|
|
||||||
|
let expected = "\
|
||||||
|
For the Doctor Watsons of this world, as opposed to the Sherlock
|
||||||
|
be, to a very large extent, the result of luck. Sherlock Holmes
|
||||||
|
";
|
||||||
|
eqnice!(expected, cmd.stdout());
|
||||||
|
});
|
||||||
|
|
||||||
rgtest!(compressed_failing_gzip, |dir: Dir, mut cmd: TestCommand| {
|
rgtest!(compressed_failing_gzip, |dir: Dir, mut cmd: TestCommand| {
|
||||||
if !cmd_exists("gzip") {
|
if !cmd_exists("gzip") {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user