summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2016-11-06 18:23:50 -0500
committerAndrew Gallant <jamslam@gmail.com>2016-11-06 18:23:50 -0500
commit9fc9f368f5dc3d7d78fb8e68bea1c0a07a2aa32f (patch)
tree99a8578bcbf767f60f5d7261b0404341b2705ca1 /src
parent9cab076a723afaeca96972a0e94c10f505b63bac (diff)
Always search paths given by user.
This permits doing `rg -a test /dev/sda1` for example, where as before /dev/sda1 was skipped because it wasn't a regular file.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 41f13be8..8b7a267d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -271,10 +271,19 @@ fn get_or_log_dir_entry(
eprintln!("{}", err);
}
}
- if !dent.file_type().map_or(true, |x| x.is_file()) {
- None
- } else {
+ // A depth of 0 means the user gave the path explicitly, so we
+ // should always try to search it.
+ if dent.depth() == 0 {
+ return Some(dent);
+ }
+ let ft = match dent.file_type() {
+ None => return Some(dent), // entry is stdin
+ Some(ft) => ft,
+ };
+ if ft.is_file() {
Some(dent)
+ } else {
+ None
}
}
}