Warn for possible bad quote nesting like 'echo 'foo''
This commit is contained in:
parent
651bab73de
commit
499f7c8733
|
@ -120,6 +120,7 @@ basicChecks = [
|
||||||
,checkSudoRedirect
|
,checkSudoRedirect
|
||||||
,checkPS1Assignments
|
,checkPS1Assignments
|
||||||
,checkBackticks
|
,checkBackticks
|
||||||
|
,checkInexplicablyUnquoted
|
||||||
]
|
]
|
||||||
treeChecks = [
|
treeChecks = [
|
||||||
checkUnquotedExpansions
|
checkUnquotedExpansions
|
||||||
|
@ -1075,6 +1076,17 @@ checkIndirectExpansion (T_DollarBraced id (T_NormalWord _ ((T_Literal _ s):attem
|
||||||
else return ()
|
else return ()
|
||||||
checkIndirectExpansion _ = return ()
|
checkIndirectExpansion _ = return ()
|
||||||
|
|
||||||
|
prop_checkInexplicablyUnquoted1 = verify checkInexplicablyUnquoted "echo 'var='value';'"
|
||||||
|
prop_checkInexplicablyUnquoted2 = verifyNot checkInexplicablyUnquoted "'foo'*"
|
||||||
|
prop_checkInexplicablyUnquoted3 = verifyNot checkInexplicablyUnquoted "wget --user-agent='something'"
|
||||||
|
checkInexplicablyUnquoted (T_NormalWord id tokens) = mapM_ check (tails tokens)
|
||||||
|
where
|
||||||
|
check ((T_SingleQuoted _ _):(T_Literal id str):_)
|
||||||
|
| all isAlphaNum str =
|
||||||
|
info id $ "This word is outside of quotes. Did you intend to 'nest '\"'single quotes'\"' instead'? "
|
||||||
|
check _ = return ()
|
||||||
|
checkInexplicablyUnquoted _ = return ()
|
||||||
|
|
||||||
--- Subshell detection
|
--- Subshell detection
|
||||||
|
|
||||||
prop_subshellAssignmentCheck = verifyFull subshellAssignmentCheck "cat foo | while read bar; do a=$bar; done; echo \"$a\""
|
prop_subshellAssignmentCheck = verifyFull subshellAssignmentCheck "cat foo | while read bar; do a=$bar; done; echo \"$a\""
|
||||||
|
|
Loading…
Reference in New Issue