mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-26 01:31:57 -07:00
ripgrep: when given no patterns, don't match
Generally speaking, ripgrep prevents the case of not having any patterns via its arg parsing. However, it is possible for users to provide a file of patterns via the `-f` flag. If that file is empty, then ripgrep has nothing to search for and therefore should not ever produce any match. One way of fixing this might be to replace the absence of patterns with a pattern that can never match, but this still requires opening and searching through every file, which is quite a waste. Instead, we detect this case explicitly and quit early. Fixes #900
This commit is contained in:
@@ -1320,6 +1320,12 @@ clean!(regression_807, "test", ".", |wd: WorkDir, mut cmd: Command| {
|
||||
assert_eq!(lines, format!("{}:test\n", path(".a/c/file")));
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/900
|
||||
sherlock!(regression_900, "-fpat", "sherlock", |wd: WorkDir, mut cmd: Command| {
|
||||
wd.create("pat", "");
|
||||
wd.assert_err(&mut cmd);
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/1
|
||||
clean!(feature_1_sjis, "Шерлок Холмс", ".", |wd: WorkDir, mut cmd: Command| {
|
||||
let sherlock =
|
||||
|
Reference in New Issue
Block a user