mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-07 21:41:34 -07:00
Track whether braces were present in T_DollarBraced
References of the form $var and ${var} both map to the same structure in the AST, which prevents any later analysis functions from distinguishing them. In preparation for adding checks that need this info, add a Bool to T_DollarBraced that tracks whether the braces were seen at parsing time and update all references so that this change is a no-op.
This commit is contained in:
parent
0358090b3c
commit
aa3b709b5d
7 changed files with 33 additions and 34 deletions
|
@ -510,7 +510,7 @@ getModifiedVariables t =
|
|||
guard . not . null $ str
|
||||
return (t, token, str, DataString SourceChecked)
|
||||
|
||||
T_DollarBraced _ l -> maybeToList $ do
|
||||
T_DollarBraced _ _ l -> maybeToList $ do
|
||||
let string = bracedString t
|
||||
let modifier = getBracedModifier string
|
||||
guard $ ":=" `isPrefixOf` modifier
|
||||
|
@ -702,7 +702,7 @@ getOffsetReferences mods = fromMaybe [] $ do
|
|||
|
||||
getReferencedVariables parents t =
|
||||
case t of
|
||||
T_DollarBraced id l -> let str = bracedString t in
|
||||
T_DollarBraced id _ l -> let str = bracedString t in
|
||||
(t, t, getBracedReference str) :
|
||||
map (\x -> (l, l, x)) (
|
||||
getIndexReferences str
|
||||
|
@ -897,7 +897,7 @@ shouldIgnoreCode params code t =
|
|||
getPath (parentMap params) t
|
||||
|
||||
-- Is this a ${#anything}, to get string length or array count?
|
||||
isCountingReference (T_DollarBraced id token) =
|
||||
isCountingReference (T_DollarBraced id _ token) =
|
||||
case concat $ oversimplify token of
|
||||
'#':_ -> True
|
||||
_ -> False
|
||||
|
@ -906,7 +906,7 @@ isCountingReference _ = False
|
|||
-- FIXME: doesn't handle ${a:+$var} vs ${a:+"$var"}
|
||||
isQuotedAlternativeReference t =
|
||||
case t of
|
||||
T_DollarBraced _ _ ->
|
||||
T_DollarBraced _ _ _ ->
|
||||
getBracedModifier (bracedString t) `matches` re
|
||||
_ -> False
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue