diff options
author | Andrew Gallant <jamslam@gmail.com> | 2018-08-27 21:17:58 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-08-27 21:18:53 -0400 |
commit | 87b745454d34786029fab9c63402572c5195ac3d (patch) | |
tree | a44331a5b9b494c81131402a922515fe08aac2db /src/args.rs | |
parent | e5bb750995b1367f424f0b6b6a5c4385b7938c2f (diff) |
ripgrep: use 'ignore' for skipping stdout
This removes ripgrep-specific code for filtering files that correspond to
stdout and instead uses the 'ignore' crate's functionality for doing the
same.
Diffstat (limited to 'src/args.rs')
-rw-r--r-- | src/args.rs | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/src/args.rs b/src/args.rs index 674b2af5..de84f094 100644 --- a/src/args.rs +++ b/src/args.rs @@ -308,9 +308,7 @@ impl Args { /// file or a stream such as stdin. pub fn subject_builder(&self) -> SubjectBuilder { let mut builder = SubjectBuilder::new(); - builder - .strip_dot_prefix(self.using_default_path()) - .skip(self.matches().stdout_handle()); + builder.strip_dot_prefix(self.using_default_path()); builder } @@ -779,6 +777,7 @@ impl ArgMatches { .max_filesize(self.max_file_size()?) .threads(self.threads()?) .same_file_system(self.is_present("one-file-system")) + .skip_stdout(true) .overrides(self.overrides()?) .types(self.types()?) .hidden(!self.hidden()) @@ -1375,28 +1374,6 @@ impl ArgMatches { self.output_kind() == OutputKind::JSON || self.is_present("stats") } - /// Returns a handle to stdout for filtering search. - /// - /// A handle is returned if and only if ripgrep's stdout is being - /// redirected to a file. The handle returned corresponds to that file. - /// - /// This can be used to ensure that we do not attempt to search a file - /// that ripgrep is writing to. - fn stdout_handle(&self) -> Option<Handle> { - let h = match Handle::stdout() { - Err(_) => return None, - Ok(h) => h, - }; - let md = match h.as_file().metadata() { - Err(_) => return None, - Ok(md) => md, - }; - if !md.is_file() { - return None; - } - Some(h) - } - /// When the output format is `Summary`, this returns the type of summary /// output to show. /// |