mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-12 16:13:19 -07:00
Add handling for special characters in parameter substitutions.
Fixes koalaman/shellcheck#562. Special characters inside braces are parsed into T_ParamSubSpecialChar instead of T_Literal so that they are not flagged in the function checkInexplicablyUnquoted when sandwiched between double quotes.
This commit is contained in:
parent
9703f89f79
commit
0897ab7092
3 changed files with 13 additions and 2 deletions
|
@ -1324,6 +1324,7 @@ prop_checkInexplicablyUnquoted3 = verifyNot checkInexplicablyUnquoted "wget --us
|
|||
prop_checkInexplicablyUnquoted4 = verify checkInexplicablyUnquoted "echo \"VALUES (\"id\")\""
|
||||
prop_checkInexplicablyUnquoted5 = verifyNot checkInexplicablyUnquoted "\"$dir\"/\"$file\""
|
||||
prop_checkInexplicablyUnquoted6 = verifyNot checkInexplicablyUnquoted "\"$dir\"some_stuff\"$file\""
|
||||
prop_checkInexplicablyUnquoted7 = verifyNot checkInexplicablyUnquoted "${dir/\"foo\"/\"bar\"}"
|
||||
checkInexplicablyUnquoted _ (T_NormalWord id tokens) = mapM_ check (tails tokens)
|
||||
where
|
||||
check (T_SingleQuoted _ _:T_Literal id str:_)
|
||||
|
@ -1352,7 +1353,7 @@ checkInexplicablyUnquoted _ (T_NormalWord id tokens) = mapM_ check (tails tokens
|
|||
warnAboutExpansion id =
|
||||
warn id 2027 "The surrounding quotes actually unquote this. Remove or escape them."
|
||||
warnAboutLiteral id =
|
||||
warn id 2140 "Word is on the form \"A\"B\"C\" (B indicated). Did you mean \"ABC\" or \"A\\\"B\\\"C\"?"
|
||||
warn id 2140 "Word is of the form \"A\"B\"C\" (B indicated). Did you mean \"ABC\" or \"A\\\"B\\\"C\"?"
|
||||
checkInexplicablyUnquoted _ _ = return ()
|
||||
|
||||
prop_checkTildeInQuotes1 = verify checkTildeInQuotes "var=\"~/out.txt\""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue