From adfdc0a627e41f488a9a53189fc2b5648c68a7ff Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 27 Nov 2012 00:48:09 -0800 Subject: [PATCH] Added check for a=ls -l --- ShellCheck/Analytics.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index 419f6f8..ad3b235 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -65,6 +65,7 @@ basicChecks = [ ,checkConstantIfs ,checkTrAZ ,checkPipedAssignment + ,checkAssignAteCommand ] modifyMap = modify @@ -141,9 +142,16 @@ prop_checkPipedAssignment1 = verify checkPipedAssignment "A=ls | grep foo" prop_checkPipedAssignment2 = verifyNot checkPipedAssignment "A=foo cmd | grep foo" prop_checkPipedAssignment3 = verifyNot checkPipedAssignment "A=foo" checkPipedAssignment (T_Pipeline _ (T_Redirecting _ _ (T_SimpleCommand id (_:_) []):_:_)) = - warn id "If you wanted to assign the output of the pipeline, use a=$(b | c)" + warn id "If you wanted to assign the output of the pipeline, use a=$(b | c) ." checkPipedAssignment _ = return () +prop_checkAssignAteCommand1 = verify checkAssignAteCommand "A=ls -l" +prop_checkAssignAteCommand2 = verify checkAssignAteCommand "A=ls --sort=$foo" +prop_checkAssignAteCommand3 = verifyNot checkAssignAteCommand "A=foo ls -l" +checkAssignAteCommand (T_SimpleCommand id (t:[]) (w:_)) | "-" `isPrefixOf` (concat $ deadSimple w) = + warn id "To assign the output of a command, use var=$(cmd) ." +checkAssignAteCommand _ = return () + prop_checkUuoc = verify checkUuoc "cat foo | grep bar" checkUuoc (T_Pipeline _ (T_Redirecting _ _ f@(T_SimpleCommand id _ _):_:_)) =