mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-08 05:51:09 -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
|
@ -278,7 +278,7 @@ checkTrapQuotes = CommandCheck (Exactly "trap") (f . arguments) where
|
|||
warning id = warn id 2064 "Use single quotes, otherwise this expands now rather than when signalled."
|
||||
checkExpansions (T_DollarExpansion id _) = warning id
|
||||
checkExpansions (T_Backticked id _) = warning id
|
||||
checkExpansions (T_DollarBraced id _) = warning id
|
||||
checkExpansions (T_DollarBraced id _ _) = warning id
|
||||
checkExpansions (T_DollarArithmetic id _) = warning id
|
||||
checkExpansions _ = return ()
|
||||
|
||||
|
@ -896,7 +896,7 @@ checkCatastrophicRm = CommandCheck (Basename "rm") $ \t ->
|
|||
getPotentialPath = getLiteralStringExt f
|
||||
where
|
||||
f (T_Glob _ str) = return str
|
||||
f (T_DollarBraced _ word) =
|
||||
f (T_DollarBraced _ _ word) =
|
||||
let var = onlyLiteralString word in
|
||||
-- This shouldn't handle non-colon cases.
|
||||
if any (`isInfixOf` var) [":?", ":-", ":="]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue