diff --git a/CHANGELOG.md b/CHANGELOG.md index 08e0ed1..90e9e23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. +- Fix bug where passing "-" as a directory argument didn't actually search that directory, see #849 (@Sean-Kenneth-Doherty). # 10.4.2 diff --git a/src/cli.rs b/src/cli.rs index 9c54d7c..638a042 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -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() } diff --git a/tests/tests.rs b/tests/tests.rs index aa0919c..0340cdd 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -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() {