Don't warn about quoting variables in [ -v 'bar[$foo]' ]

This commit is contained in:
Vidar Holen 2017-04-15 10:57:10 -07:00
parent faafc99704
commit 1fd9b474ba
1 changed files with 2 additions and 0 deletions

View File

@ -791,6 +791,7 @@ prop_checkSingleQuotedVariables10= verify checkSingleQuotedVariables "echo '`pwd
prop_checkSingleQuotedVariables11= verifyNot checkSingleQuotedVariables "sed '${/lol/d}'" prop_checkSingleQuotedVariables11= verifyNot checkSingleQuotedVariables "sed '${/lol/d}'"
prop_checkSingleQuotedVariables12= verifyNot checkSingleQuotedVariables "eval 'echo $1'" prop_checkSingleQuotedVariables12= verifyNot checkSingleQuotedVariables "eval 'echo $1'"
prop_checkSingleQuotedVariables13= verifyNot checkSingleQuotedVariables "busybox awk '{print $1}'" prop_checkSingleQuotedVariables13= verifyNot checkSingleQuotedVariables "busybox awk '{print $1}'"
prop_checkSingleQuotedVariables14= verifyNot checkSingleQuotedVariables "[ -v 'bar[$foo]' ]"
checkSingleQuotedVariables params t@(T_SingleQuoted id s) = checkSingleQuotedVariables params t@(T_SingleQuoted id s) =
when (s `matches` re) $ when (s `matches` re) $
if "sed" == commandName if "sed" == commandName
@ -828,6 +829,7 @@ checkSingleQuotedVariables params t@(T_SingleQuoted id s) =
isOkAssignment t = isOkAssignment t =
case t of case t of
T_Assignment _ _ name _ _ -> name `elem` commonlyQuoted T_Assignment _ _ name _ _ -> name `elem` commonlyQuoted
TC_Unary _ _ "-v" _ -> True
_ -> False _ -> False
re = mkRegex "\\$[{(0-9a-zA-Z_]|`.*`" re = mkRegex "\\$[{(0-9a-zA-Z_]|`.*`"