mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-21 11:20:24 +08:00
Make 2077 point to the = in [ foo=bar ]
This commit is contained in:
@@ -1285,9 +1285,15 @@ checkConstantIfs _ _ = return ()
|
|||||||
prop_checkNoaryWasBinary = verify checkNoaryWasBinary "[[ a==$foo ]]"
|
prop_checkNoaryWasBinary = verify checkNoaryWasBinary "[[ a==$foo ]]"
|
||||||
prop_checkNoaryWasBinary2 = verify checkNoaryWasBinary "[ $foo=3 ]"
|
prop_checkNoaryWasBinary2 = verify checkNoaryWasBinary "[ $foo=3 ]"
|
||||||
prop_checkNoaryWasBinary3 = verify checkNoaryWasBinary "[ $foo!=3 ]"
|
prop_checkNoaryWasBinary3 = verify checkNoaryWasBinary "[ $foo!=3 ]"
|
||||||
checkNoaryWasBinary _ (TC_Noary _ _ t@(T_NormalWord id l)) | not $ isConstant t = do
|
checkNoaryWasBinary _ (TC_Noary _ _ t@(T_NormalWord _ l)) | not $ isConstant t = potentially $ do
|
||||||
let str = concat $ deadSimple t
|
token <- getEqualsPart
|
||||||
when ('=' `elem` str) $ err id 2077 "You need spaces around the comparison operator."
|
return $ err (getId token) 2077 "You need spaces around the comparison operator."
|
||||||
|
where
|
||||||
|
hasEquals t = isJust $ do
|
||||||
|
str <- getLiteralString t
|
||||||
|
guard $ '=' `elem` str
|
||||||
|
return ()
|
||||||
|
getEqualsPart = listToMaybe $ filter hasEquals l
|
||||||
checkNoaryWasBinary _ _ = return ()
|
checkNoaryWasBinary _ _ = return ()
|
||||||
|
|
||||||
prop_checkConstantNoary = verify checkConstantNoary "[[ '$(foo)' ]]"
|
prop_checkConstantNoary = verify checkConstantNoary "[[ '$(foo)' ]]"
|
||||||
|
Reference in New Issue
Block a user