Only perform plain in search if neither glob nor regex enabled.

This commit is contained in:
voussoir 2020-02-03 20:25:11 -08:00
parent e79001f57c
commit a5c8887f47

View file

@ -120,6 +120,8 @@ def search(
terms = {k: ([v] if isinstance(v, str) else v or []) for (k, v) in terms.items()} terms = {k: ([v] if isinstance(v, str) else v or []) for (k, v) in terms.items()}
#print(terms, content_args) #print(terms, content_args)
do_plain = not (do_glob or do_regex)
if all(v == [] for v in terms.values()) and not content_args: if all(v == [] for v in terms.values()) and not content_args:
raise ValueError('No terms supplied') raise ValueError('No terms supplied')
@ -131,7 +133,7 @@ def search(
return term.evaluate(line) return term.evaluate(line)
return ( return (
(term in line) or (do_plain and term in line) or
(do_regex and re.search(term, line)) or (do_regex and re.search(term, line)) or
(do_glob and winglob.fnmatch(line, term)) (do_glob and winglob.fnmatch(line, term))
) )