From d28f1fff56820bd29b7be49969a47022adb72ab7 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 23 Jul 2013 21:53:01 -0700 Subject: [PATCH] Tried to make [ foo=bar ] messages simpler --- ShellCheck/Analytics.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index a9ae1d2..022884d 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -718,10 +718,10 @@ checkConstantIfs _ = return () prop_checkNoaryWasBinary = verify checkNoaryWasBinary "[[ a==$foo ]]" prop_checkNoaryWasBinary2 = verify checkNoaryWasBinary "[ $foo=3 ]" -prop_checkNoaryWasBinary3 = verify checkNoaryWasBinary "[ foo!=3 ]" -checkNoaryWasBinary (TC_Noary _ _ t@(T_NormalWord id l)) = do +prop_checkNoaryWasBinary3 = verify checkNoaryWasBinary "[ $foo!=3 ]" +checkNoaryWasBinary (TC_Noary _ _ t@(T_NormalWord id l)) | not $ isConstant t = do let str = concat $ deadSimple t - when ('=' `elem` str) $ err id $ "Always true because you didn't put spaces around the operator." + when ('=' `elem` str) $ err id $ "You need spaces around the comparison operator." checkNoaryWasBinary _ = return () prop_checkConstantNoary = verify checkConstantNoary "[[ '$(foo)' ]]" @@ -729,8 +729,7 @@ prop_checkConstantNoary2 = verify checkConstantNoary "[ \"-f lol\" ]" prop_checkConstantNoary3 = verify checkConstantNoary "[[ cmd ]]" prop_checkConstantNoary4 = verify checkConstantNoary "[[ ! cmd ]]" checkConstantNoary (TC_Noary _ _ t@(T_NormalWord id _)) | isConstant t = do - err id $ if isEmpty t then "Always false, just checks the non-emptyness of the literal word." - else "Always true, just checks the non-emptyness of the literal word." + err id $ "This expression is constant. Did you forget a $ somewhere?" checkConstantNoary _ = return () prop_checkBraceExpansionVars = verify checkBraceExpansionVars "echo {1..$n}"