mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-07 13:31:36 -07:00
Allow SC2154 to trigger in arrays (fixes #2970)
This commit is contained in:
parent
d705716dc4
commit
a7a906e2cb
1 changed files with 2 additions and 3 deletions
|
@ -2447,6 +2447,7 @@ prop_checkUnassignedReferences_minusZDefault = verifyNotTree checkUnassignedRefe
|
||||||
prop_checkUnassignedReferences50 = verifyNotTree checkUnassignedReferences "echo ${foo:+bar}"
|
prop_checkUnassignedReferences50 = verifyNotTree checkUnassignedReferences "echo ${foo:+bar}"
|
||||||
prop_checkUnassignedReferences51 = verifyNotTree checkUnassignedReferences "echo ${foo:+$foo}"
|
prop_checkUnassignedReferences51 = verifyNotTree checkUnassignedReferences "echo ${foo:+$foo}"
|
||||||
prop_checkUnassignedReferences52 = verifyNotTree checkUnassignedReferences "wait -p pid; echo $pid"
|
prop_checkUnassignedReferences52 = verifyNotTree checkUnassignedReferences "wait -p pid; echo $pid"
|
||||||
|
prop_checkUnassignedReferences53 = verify checkUnassignedReferences "x=($foo)"
|
||||||
|
|
||||||
checkUnassignedReferences = checkUnassignedReferences' False
|
checkUnassignedReferences = checkUnassignedReferences' False
|
||||||
checkUnassignedReferences' includeGlobals params t = warnings
|
checkUnassignedReferences' includeGlobals params t = warnings
|
||||||
|
@ -2502,14 +2503,12 @@ checkUnassignedReferences' includeGlobals params t = warnings
|
||||||
|
|
||||||
warnings = execWriter . sequence $ mapMaybe warningFor unassigned
|
warnings = execWriter . sequence $ mapMaybe warningFor unassigned
|
||||||
|
|
||||||
-- Due to parsing, foo=( [bar]=baz ) parses 'bar' as a reference even for assoc arrays.
|
-- ${foo[bar baz]} may not be referencing bar/baz. Just skip these.
|
||||||
-- Similarly, ${foo[bar baz]} may not be referencing bar/baz. Just skip these.
|
|
||||||
-- We can also have ${foo:+$foo} should be treated like [[ -n $foo ]] && echo $foo
|
-- We can also have ${foo:+$foo} should be treated like [[ -n $foo ]] && echo $foo
|
||||||
isException var t = any shouldExclude $ getPath (parentMap params) t
|
isException var t = any shouldExclude $ getPath (parentMap params) t
|
||||||
where
|
where
|
||||||
shouldExclude t =
|
shouldExclude t =
|
||||||
case t of
|
case t of
|
||||||
T_Array {} -> True
|
|
||||||
(T_DollarBraced _ _ l) ->
|
(T_DollarBraced _ _ l) ->
|
||||||
let str = concat $ oversimplify l
|
let str = concat $ oversimplify l
|
||||||
ref = getBracedReference str
|
ref = getBracedReference str
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue