Added check for [[ foo == $bar ]]
This commit is contained in:
parent
a2cc44a04d
commit
686c895858
|
@ -38,6 +38,7 @@ basicChecks = [
|
|||
,checkForDecimals
|
||||
,checkDivBeforeMult
|
||||
,checkArithmeticDeref
|
||||
,checkComparisonAgainstGlob
|
||||
]
|
||||
|
||||
modifyMap = modify
|
||||
|
@ -260,6 +261,13 @@ checkArithmeticDeref (TA_Expansion _ (T_DollarBraced id str)) | not $ any (`elem
|
|||
addNoteFor id $ Note WarningC $ "Don't use $ on variables in (( )) unless you want to dereference twice"
|
||||
checkArithmeticDeref _ = return ()
|
||||
|
||||
|
||||
prop_checkComparisonAgainstGlob = verify checkComparisonAgainstGlob "[[ $cow == $bar ]]"
|
||||
prop_checkComparisonAgainstGlob2 = verifyNot checkComparisonAgainstGlob "[[ $cow == \"$bar\" ]]"
|
||||
checkComparisonAgainstGlob (TC_Binary _ DoubleBracket op _ (T_NormalWord id [T_DollarBraced _ _])) | op == "=" || op == "==" =
|
||||
addNoteFor id $ Note WarningC $ "Quote the rhs of = in [[ ]] to prevent glob interpretation"
|
||||
checkComparisonAgainstGlob _ = return ()
|
||||
|
||||
allModifiedVariables t = snd $ runState (doAnalysis (\x -> modify $ (++) (getModifiedVariables x)) t) []
|
||||
|
||||
--- Subshell detection
|
||||
|
|
Loading…
Reference in New Issue