提交 9cfa25cb 编写于 作者: V Vidar Holen

Added check for ~ in quotes

上级 499f7c87
...@@ -121,6 +121,7 @@ basicChecks = [ ...@@ -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) ...@@ -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\""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册