mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-04-24 17:12:16 +02:00
search: fix -F and -f interaction bug
This fixes what appears to be a pretty egregious regression where the `-F/--fixed-strings` flag wasn't be applied to patterns supplied via the `-f/--file` flag. The same bug existed for the `-x/--line-regexp` flag as well, which we fix here. Fixes #1176
This commit is contained in:
parent
f3164f2615
commit
0df71240ff
@ -53,6 +53,8 @@ Bug fixes:
|
|||||||
Fix handling of `**` patterns in gitignore files.
|
Fix handling of `**` patterns in gitignore files.
|
||||||
* [BUG #1174](https://github.com/BurntSushi/ripgrep/issues/1174):
|
* [BUG #1174](https://github.com/BurntSushi/ripgrep/issues/1174):
|
||||||
Fix handling of repeated `**` patterns in gitignore files.
|
Fix handling of repeated `**` patterns in gitignore files.
|
||||||
|
* [BUG #1176](https://github.com/BurntSushi/ripgrep/issues/1176):
|
||||||
|
Fix bug where `-F`/`-x` weren't applied to patterns given via `-f`.
|
||||||
|
|
||||||
|
|
||||||
0.10.0 (2018-09-07)
|
0.10.0 (2018-09-07)
|
||||||
|
22
src/args.rs
22
src/args.rs
@ -1271,9 +1271,15 @@ impl ArgMatches {
|
|||||||
if let Some(paths) = self.values_of_os("file") {
|
if let Some(paths) = self.values_of_os("file") {
|
||||||
for path in paths {
|
for path in paths {
|
||||||
if path == "-" {
|
if path == "-" {
|
||||||
pats.extend(cli::patterns_from_stdin()?);
|
pats.extend(cli::patterns_from_stdin()?
|
||||||
|
.into_iter()
|
||||||
|
.map(|p| self.pattern_from_string(p))
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
pats.extend(cli::patterns_from_path(path)?);
|
pats.extend(cli::patterns_from_path(path)?
|
||||||
|
.into_iter()
|
||||||
|
.map(|p| self.pattern_from_string(p))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1302,13 +1308,17 @@ impl ArgMatches {
|
|||||||
/// Converts a &str pattern to a String pattern. The pattern is escaped
|
/// Converts a &str pattern to a String pattern. The pattern is escaped
|
||||||
/// if -F/--fixed-strings is set.
|
/// if -F/--fixed-strings is set.
|
||||||
fn pattern_from_str(&self, pat: &str) -> String {
|
fn pattern_from_str(&self, pat: &str) -> String {
|
||||||
let litpat = self.pattern_literal(pat.to_string());
|
self.pattern_from_string(pat.to_string())
|
||||||
let s = self.pattern_line(litpat);
|
}
|
||||||
|
|
||||||
if s.is_empty() {
|
/// Applies additional processing on the given pattern if necessary
|
||||||
|
/// (such as escaping meta characters or turning it into a line regex).
|
||||||
|
fn pattern_from_string(&self, pat: String) -> String {
|
||||||
|
let pat = self.pattern_line(self.pattern_literal(pat));
|
||||||
|
if pat.is_empty() {
|
||||||
self.pattern_empty()
|
self.pattern_empty()
|
||||||
} else {
|
} else {
|
||||||
s
|
pat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,3 +672,25 @@ rgtest!(r1174, |dir: Dir, mut cmd: TestCommand| {
|
|||||||
dir.create("a/foo", "test");
|
dir.create("a/foo", "test");
|
||||||
cmd.arg("test").assert_err();
|
cmd.arg("test").assert_err();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// See: https://github.com/BurntSushi/ripgrep/issues/1176
|
||||||
|
rgtest!(r1176_literal_file, |dir: Dir, mut cmd: TestCommand| {
|
||||||
|
dir.create("patterns", "foo(bar\n");
|
||||||
|
dir.create("test", "foo(bar");
|
||||||
|
|
||||||
|
eqnice!(
|
||||||
|
"foo(bar\n",
|
||||||
|
cmd.arg("-F").arg("-f").arg("patterns").arg("test").stdout()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// See: https://github.com/BurntSushi/ripgrep/issues/1176
|
||||||
|
rgtest!(r1176_line_regex, |dir: Dir, mut cmd: TestCommand| {
|
||||||
|
dir.create("patterns", "foo\n");
|
||||||
|
dir.create("test", "foobar\nfoo\nbarfoo\n");
|
||||||
|
|
||||||
|
eqnice!(
|
||||||
|
"foo\n",
|
||||||
|
cmd.arg("-x").arg("-f").arg("patterns").arg("test").stdout()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user