From 69095cf5c370b378261ca0470b3f030ddcbb7186 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 20 Sep 2016 20:25:24 -0400 Subject: Add an error message for catching a common failure mode. If you're in a directory that has a parent .gitignore (like, your $HOME), then it can cause ripgrep to simply not do anything depending on your ignore rules. There are probably other scenarios where ripgrep applies some filter that an end user doesn't expect, so try to catch the worst case (when ripgrep doesn't search anything). --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 936e4965..e4f4b4f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,15 +118,23 @@ fn run(args: Args) -> Result { } workq }; + let mut paths_searched: u64 = 0; for p in paths { if p == Path::new("-") { - workq.push(Work::Stdin) + paths_searched += 1; + workq.push(Work::Stdin); } else { for ent in try!(args.walker(p)) { + paths_searched += 1; workq.push(Work::File(ent)); } } } + if !paths.is_empty() && paths_searched == 0 { + eprintln!("No files were searched, which means ripgrep probably \ + applied a filter you didn't expect. \ + Try running again with --debug."); + } for _ in 0..workers.len() { workq.push(Work::Quit); } -- cgit v1.2.3