Inspect 'alias' commands for referenced variables (Fixes #1832)

This commit is contained in:
Vidar Holen 2020-02-17 14:20:21 -08:00
parent a75219e525
commit 4c9210af79
2 changed files with 3 additions and 1 deletions

View File

@ -2127,6 +2127,7 @@ prop_checkUnused43= verifyTree checkUnusedAssignments "DEFINE_string foo '' ''"
prop_checkUnused44= verifyNotTree checkUnusedAssignments "DEFINE_string \"foo$ibar\" x y"
prop_checkUnused45= verifyTree checkUnusedAssignments "readonly foo=bar"
prop_checkUnused46= verifyTree checkUnusedAssignments "readonly foo=(bar)"
prop_checkUnused47= verifyNotTree checkUnusedAssignments "a=1; alias hello='echo $a'"
checkUnusedAssignments params t = execWriter (mapM_ warnFor unused)
where
flow = variableFlow params

View File

@ -544,8 +544,9 @@ getReferencedVariableCommand base@(T_SimpleCommand _ _ (T_NormalWord _ (T_Litera
else []
"trap" ->
case rest of
head:_ -> map (\x -> (head, head, x)) $ getVariablesFromLiteralToken head
head:_ -> map (\x -> (base, head, x)) $ getVariablesFromLiteralToken head
_ -> []
"alias" -> [(base, token, name) | token <- rest, name <- getVariablesFromLiteralToken token]
_ -> []
where
getReference t@(T_Assignment _ _ name _ value) = [(t, t, name)]