mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-03-12 12:35:25 -07:00
Added check for ~ in quotes
This commit is contained in:
parent
499f7c8733
commit
9cfa25cb56
@ -121,6 +121,7 @@ basicChecks = [
|
||||
,checkPS1Assignments
|
||||
,checkBackticks
|
||||
,checkInexplicablyUnquoted
|
||||
,checkTildeInQuotes
|
||||
]
|
||||
treeChecks = [
|
||||
checkUnquotedExpansions
|
||||
@ -1087,6 +1088,24 @@ checkInexplicablyUnquoted (T_NormalWord id tokens) = mapM_ check (tails tokens)
|
||||
check _ = 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
|
||||
|
||||
prop_subshellAssignmentCheck = verifyFull subshellAssignmentCheck "cat foo | while read bar; do a=$bar; done; echo \"$a\""
|
||||
|
Loading…
x
Reference in New Issue
Block a user