diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index 4d6f25e..813dc06 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -120,6 +120,7 @@ basicChecks = [ ,checkSudoRedirect ,checkPS1Assignments ,checkBackticks + ,checkInexplicablyUnquoted ] treeChecks = [ checkUnquotedExpansions @@ -1075,6 +1076,17 @@ checkIndirectExpansion (T_DollarBraced id (T_NormalWord _ ((T_Literal _ s):attem else 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 prop_subshellAssignmentCheck = verifyFull subshellAssignmentCheck "cat foo | while read bar; do a=$bar; done; echo \"$a\""