summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2016-11-17 20:48:11 -0500
committerAndrew Gallant <jamslam@gmail.com>2016-11-17 20:48:11 -0500
commit0302d58eb8b064da91e67de00aa25f542d1ff666 (patch)
tree5ee45d09761ab90802e8312ee31a7c995f43b03e
parente37f783fc00e9fa0e27450315c1e756918294e04 (diff)
Fix stdin bug with --file.
When `rg -f-` is used, the default search path should be `./` and not `-`.
-rw-r--r--src/args.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/args.rs b/src/args.rs
index 97cf24fe..a4955d5f 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -370,10 +370,15 @@ impl<'a> ArgMatches<'a> {
/// Return the default path that ripgrep should search.
fn default_path(&self) -> PathBuf {
+ let file_is_stdin =
+ self.values_of_os("file").map_or(false, |mut files| {
+ files.any(|f| f == "-")
+ });
let search_cwd = atty::on_stdin()
+ || !atty::stdin_is_readable()
+ || (self.is_present("file") && file_is_stdin)
|| self.is_present("files")
- || self.is_present("type-list")
- || !atty::stdin_is_readable();
+ || self.is_present("type-list");
if search_cwd {
Path::new("./").to_path_buf()
} else {