Don't consider `.*` a glob-like regex (fixes #1214)
This commit is contained in:
parent
c0d3a98fcd
commit
914974bd4f
|
@ -791,7 +791,7 @@ isCommandMatch token matcher = fromMaybe False $
|
||||||
-- False: .*foo.*
|
-- False: .*foo.*
|
||||||
isConfusedGlobRegex :: String -> Bool
|
isConfusedGlobRegex :: String -> Bool
|
||||||
isConfusedGlobRegex ('*':_) = True
|
isConfusedGlobRegex ('*':_) = True
|
||||||
isConfusedGlobRegex [x,'*'] | x /= '\\' = True
|
isConfusedGlobRegex [x,'*'] | x `notElem` "\\." = True
|
||||||
isConfusedGlobRegex _ = False
|
isConfusedGlobRegex _ = False
|
||||||
|
|
||||||
isVariableStartChar x = x == '_' || isAsciiLower x || isAsciiUpper x
|
isVariableStartChar x = x == '_' || isAsciiLower x || isAsciiUpper x
|
||||||
|
|
|
@ -214,6 +214,9 @@ prop_checkGrepRe17= verifyNot checkGrepRe "grep --exclude 'Foo*' file"
|
||||||
prop_checkGrepRe18= verifyNot checkGrepRe "grep --exclude-dir 'Foo*' file"
|
prop_checkGrepRe18= verifyNot checkGrepRe "grep --exclude-dir 'Foo*' file"
|
||||||
prop_checkGrepRe19= verify checkGrepRe "grep -- 'Foo*' file"
|
prop_checkGrepRe19= verify checkGrepRe "grep -- 'Foo*' file"
|
||||||
prop_checkGrepRe20= verifyNot checkGrepRe "grep --fixed-strings 'Foo*' file"
|
prop_checkGrepRe20= verifyNot checkGrepRe "grep --fixed-strings 'Foo*' file"
|
||||||
|
prop_checkGrepRe21= verifyNot checkGrepRe "grep -o 'x*' file"
|
||||||
|
prop_checkGrepRe22= verifyNot checkGrepRe "grep --only-matching 'x*' file"
|
||||||
|
prop_checkGrepRe23= verifyNot checkGrepRe "grep '.*' file"
|
||||||
|
|
||||||
checkGrepRe = CommandCheck (Basename "grep") check where
|
checkGrepRe = CommandCheck (Basename "grep") check where
|
||||||
check cmd = f cmd (arguments cmd)
|
check cmd = f cmd (arguments cmd)
|
||||||
|
@ -246,7 +249,7 @@ checkGrepRe = CommandCheck (Basename "grep") check where
|
||||||
"Note that unlike globs, " ++ [char] ++ "* here matches '" ++ [char, char, char] ++ "' but not '" ++ wordStartingWith char ++ "'."
|
"Note that unlike globs, " ++ [char] ++ "* here matches '" ++ [char, char, char] ++ "' but not '" ++ wordStartingWith char ++ "'."
|
||||||
where
|
where
|
||||||
flags = map snd $ getAllFlags cmd
|
flags = map snd $ getAllFlags cmd
|
||||||
grepGlobFlags = ["fixed-strings", "F", "include", "exclude", "exclude-dir"]
|
grepGlobFlags = ["fixed-strings", "F", "include", "exclude", "exclude-dir", "o", "only-matching"]
|
||||||
|
|
||||||
wordStartingWith c =
|
wordStartingWith c =
|
||||||
head . filter ([c] `isPrefixOf`) $ candidates
|
head . filter ([c] `isPrefixOf`) $ candidates
|
||||||
|
|
Loading…
Reference in New Issue