mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-10 15:22:58 -07:00
Warn about flipped $ and " in $"(cmd)" (fixes #1517)
This commit is contained in:
parent
c53c8a5ead
commit
f514f5f735
2 changed files with 15 additions and 0 deletions
|
@ -171,6 +171,7 @@ nodeChecks = [
|
|||
,checkInvertedStringTest
|
||||
,checkRedirectionToCommand
|
||||
,checkNullaryExpansionTest
|
||||
,checkDollarQuoteParen
|
||||
]
|
||||
|
||||
|
||||
|
@ -3169,5 +3170,18 @@ checkNullaryExpansionTest params t =
|
|||
fix = fixWith [replaceStart id params 0 "-n "]
|
||||
_ -> return ()
|
||||
|
||||
|
||||
prop_checkDollarQuoteParen1 = verify checkDollarQuoteParen "$\"(foo)\""
|
||||
prop_checkDollarQuoteParen2 = verify checkDollarQuoteParen "$\"{foo}\""
|
||||
prop_checkDollarQuoteParen3 = verifyNot checkDollarQuoteParen "\"$(foo)\""
|
||||
prop_checkDollarQuoteParen4 = verifyNot checkDollarQuoteParen "$\"..\""
|
||||
checkDollarQuoteParen params t =
|
||||
case t of
|
||||
T_DollarDoubleQuoted id ((T_Literal _ (c:_)):_) | c `elem` "({" ->
|
||||
warnWithFix id 2247 "Flip leading $ and \" if this should be a quoted substitution." (fix id)
|
||||
_ -> return ()
|
||||
where
|
||||
fix id = fixWith [replaceStart id params 2 "\"$"]
|
||||
|
||||
return []
|
||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue