Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grep-cli: Support files compressed by compress(1) #1547

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/cli/src/decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ fn default_decompression_commands() -> Vec<DecompressionCommand> {
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 {
Expand All @@ -372,5 +373,6 @@ fn default_decompression_commands() -> Vec<DecompressionCommand> {
cmd("*.br", ARGS_BROTLI),
cmd("*.zst", ARGS_ZSTD),
cmd("*.zstd", ARGS_ZSTD),
cmd("*.Z", ARGS_UNCOMPRESS),
]
}
1 change: 1 addition & 0 deletions crates/ignore/src/default_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Binary file added tests/data/sherlock.Z
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,21 @@ be, to a very large extent, the result of luck. Sherlock Holmes
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| {
if !cmd_exists("gzip") {
return;
Expand Down