Treat single dash as search path

This commit is contained in:
Sean Doherty
2026-05-16 17:15:00 -05:00
parent 7f1b1471d5
commit 8dfa67a245
3 changed files with 12 additions and 0 deletions
+1
View File
@@ -6,6 +6,7 @@
## Bugfixes
- Handle invalid working directories gracefully when using `--full-path`, see #1900 (@Xavrir).
- Fire the "search pattern contains a path separator" diagnostic for any pattern containing `/`, not just patterns that happen to name an existing directory. Preserves the legacy Windows behaviour that also flags native `\` separators when the pattern resolves to a real directory. See #1873.
- Treat `-` as a literal search path when a directory with that name exists, see #849 (@Sean-Kenneth-Doherty).
# 10.4.2
+4
View File
@@ -712,6 +712,10 @@ impl Opts {
} else if path == Path::new(".") {
// Change "." to "./" as a workaround for https://github.com/BurntSushi/ripgrep/pull/2711
PathBuf::from("./")
} else if path == Path::new("-") {
// Prefix "-" so the underlying walker treats it as a path.
// See sharkdp/fd#849.
Path::new(".").join(path)
} else {
path.to_path_buf()
}
+7
View File
@@ -459,6 +459,13 @@ fn test_explicit_root_path() {
);
}
#[test]
fn test_single_dash_root_path() {
let te = TestEnv::new(&["-"], &["-/foo"]);
te.assert_output(&[".", "-"], "./-/foo");
}
/// Regex searches
#[test]
fn test_regex_searches() {