Added check for ~ in quotes
This commit is contained in:
parent
499f7c8733
commit
9cfa25cb56
|
@ -121,6 +121,7 @@ basicChecks = [
|
||||||
,checkPS1Assignments
|
,checkPS1Assignments
|
||||||
,checkBackticks
|
,checkBackticks
|
||||||
,checkInexplicablyUnquoted
|
,checkInexplicablyUnquoted
|
||||||
|
,checkTildeInQuotes
|
||||||
]
|
]
|
||||||
treeChecks = [
|
treeChecks = [
|
||||||
checkUnquotedExpansions
|
checkUnquotedExpansions
|
||||||
|
@ -1087,6 +1088,24 @@ checkInexplicablyUnquoted (T_NormalWord id tokens) = mapM_ check (tails tokens)
|
||||||
check _ = return ()
|
check _ = return ()
|
||||||
checkInexplicablyUnquoted _ = return ()
|
checkInexplicablyUnquoted _ = return ()
|
||||||
|
|
||||||
|
prop_checkTildeInQuotes1 = verify checkTildeInQuotes "var=\"~/out.txt\""
|
||||||
|
prop_checkTildeInQuotes2 = verify checkTildeInQuotes "foo > '~/dir'"
|
||||||
|
prop_checkTildeInQuotes3 = verify checkTildeInQuotes "args='-s ~/dir'"
|
||||||
|
prop_checkTildeInQuotes4 = verifyNot checkTildeInQuotes "~/file"
|
||||||
|
prop_checkTildeInQuotes5 = verifyNot checkTildeInQuotes "echo '/~foo/cow'"
|
||||||
|
checkTildeInQuotes = check
|
||||||
|
where
|
||||||
|
post f = f "Note that ~ does not expand in quotes"
|
||||||
|
verify id ('~':_) = post (warn id)
|
||||||
|
verify id str =
|
||||||
|
when (isJust $ matchRegex re str) $ post (info id)
|
||||||
|
re = mkRegex "\\s~"
|
||||||
|
check (T_NormalWord _ ((T_SingleQuoted id str):_)) =
|
||||||
|
verify id str
|
||||||
|
check (T_NormalWord _ ((T_DoubleQuoted _ ((T_Literal id str):_)):_)) =
|
||||||
|
verify id str
|
||||||
|
check _ = 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