From 10d4abf235534cc33791f49e309fcbbc34c41c15 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 14 May 2013 15:23:28 -0700 Subject: [PATCH] Warn for test n > 4 --- ShellCheck/Analytics.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index 0488724..2dcd4c0 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -81,6 +81,7 @@ basicChecks = [ ,checkValidCondOps ,checkGlobbedRegex ,checkTrapQuotes + ,checkTestRedirects ] treeChecks = [ checkUnquotedExpansions @@ -850,6 +851,12 @@ checkTrapQuotes = checkCommand "trap" f where checkExpansions (T_DollarArithmetic id _) = warning id checkExpansions _ = return () +prop_checkTestRedirects1 = verify checkTestRedirects "test 3 > 1" +prop_checkTestRedirects2 = verifyNot checkTestRedirects "test 3 \\> 1" +prop_checkTestRedirects3 = verify checkTestRedirects "/usr/bin/test $var > $foo" +checkTestRedirects (T_Redirecting id redirs@(redir:_) cmd) | cmd `isCommand` "test" = + warn (getId redir) $ "This is interpretted as a shell file redirection, not a comparison." +checkTestRedirects _ = return () --- Subshell detection