mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-08 00:07:56 +08:00
Don't consider .*
a glob-like regex (fixes #1214)
This commit is contained in:
@@ -791,7 +791,7 @@ isCommandMatch token matcher = fromMaybe False $
|
||||
-- False: .*foo.*
|
||||
isConfusedGlobRegex :: String -> Bool
|
||||
isConfusedGlobRegex ('*':_) = True
|
||||
isConfusedGlobRegex [x,'*'] | x /= '\\' = True
|
||||
isConfusedGlobRegex [x,'*'] | x `notElem` "\\." = True
|
||||
isConfusedGlobRegex _ = False
|
||||
|
||||
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_checkGrepRe19= verify checkGrepRe "grep -- '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
|
||||
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 ++ "'."
|
||||
where
|
||||
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 =
|
||||
head . filter ([c] `isPrefixOf`) $ candidates
|
||||
|
Reference in New Issue
Block a user