From 509e5817e6e035e762840c00fb95b18253b1d269 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 25 Apr 2020 12:56:47 +0200 Subject: only try regex if word doesn't start with - Since our predicates start with -, this sounds like a good heuristic to prevent something like "raidgrep -- -player" from silently succeeding but not doing what the user had intended. In this case, we want the parse error to show and not treat "-player" as a regex. --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 66b2880..3164bd4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -262,7 +262,7 @@ fn single(opt: &Opt) -> Result<()> { if opt.expression.len() == 1 { let line = &opt.expression[0]; let maybe_filter = build_filter(line); - if maybe_filter.is_err() { + if maybe_filter.is_err() && !line.starts_with('-') { let maybe_regex = Regex::new(line); if let Ok(rgx) = maybe_regex { let filter = filters::player::any( -- cgit v1.2.3