From 0302d58eb8b064da91e67de00aa25f542d1ff666 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Thu, 17 Nov 2016 20:48:11 -0500 Subject: Fix stdin bug with --file. When `rg -f-` is used, the default search path should be `./` and not `-`. --- src/args.rs | 9 +++++++-- 1 file 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 { -- cgit v1.2.3