Added check for [ a==b ]

This commit is contained in:
Vidar Holen 2012-11-08 20:43:51 -08:00
parent 947ae519a2
commit f9f2982c9f
2 changed files with 8 additions and 1 deletions

View File

@ -33,6 +33,7 @@ basicChecks = [
,checkSingleQuotedVariables ,checkSingleQuotedVariables
,checkUnquotedZN ,checkUnquotedZN
,checkNumberComparisons ,checkNumberComparisons
,checkNoaryWasBinary
] ]
modifyMap = modify modifyMap = modify
@ -225,6 +226,13 @@ checkNumberComparisons (TC_Binary id typ op lhs rhs)
eqv _ = "the numerical equivalent" eqv _ = "the numerical equivalent"
checkNumberComparisons _ = return () checkNumberComparisons _ = return ()
prop_checkNoaryWasBinary = verify checkNoaryWasBinary "[[ a==$foo ]]"
prop_checkNoaryWasBinary2 = verify checkNoaryWasBinary "[ $foo=3 ]"
checkNoaryWasBinary (TC_Noary _ _ t@(T_NormalWord id l)) = do
let str = concat $ deadSimple t
when ('=' `elem` str) $ addNoteFor id $ Note ErrorC $ "Always true because you didn't put spaces around the ="
checkNoaryWasBinary _ = return ()
allModifiedVariables t = snd $ runState (doAnalysis (\x -> modify $ (++) (getModifiedVariables t)) t) [] allModifiedVariables t = snd $ runState (doAnalysis (\x -> modify $ (++) (getModifiedVariables t)) t) []
--- Subshell detection --- Subshell detection

View File

@ -146,7 +146,6 @@ acceptButWarn parser level note = do
) )
prop_readConditionContents = isWarning readCondition "[ grep -q file dir ]"
readConditionContents single = do readConditionContents single = do
readCondOr `attempting` (lookAhead $ do readCondOr `attempting` (lookAhead $ do
pos <- getPosition pos <- getPosition