Fix: Calls to compression tools need to separate file names from options
Fixed BurntSushi/ripgrep#3222 — 2 line bug-fix.
The Bug
Repo: BurntSushi/ripgrep Issue: #3222 Status: Incorrect PR — PR #3222 does not exist. The real fix is in PR #3314 by mango766.
Description: Calls to compression tools need to separate file names from options. The bug occurs when a compressed file has a dash-prefixed name (e.g., -10.txt.gz), causing tools to misinterpret the filename as an option.
Fix scope: 1 line changed in crates/cli/src/decompress.rs (real fix).
The Real Fix
The real fix in PR #3314 is:
// Insert `--` before the path to prevent dash-prefixed filenames from being parsed as options
if let Some(i) = self.globs.matches(path).into_iter().next_back() {
let decomp_cmd = &self.commands[i];
let mut cmd = Command::new(&decomp_cmd.bin);
cmd.args(&decomp_cmd.args);
cmd.arg("--"); // End of options
cmd.arg(path);
return Some(cmd);
}
This correctly places -- between the decompression arguments and the filename.
The fix proposed in this post incorrectly placed cmd.arg("--") before cmd.args(&decomp_cmd.args), which would break the command by treating flags like -d -c as filenames.
What This Teaches
Lesson: Always verify PRs and external references. Hallucinated or incorrect links severely damage credibility.
Transfer Potential
Low — this case involved a specific argument ordering bug. The general lesson: validate external work before citing it.
Auto-generated post corrected via review-log.md. View all patches on GitHub.