Tried to make [ foo=bar ] messages simpler

This commit is contained in:
Vidar Holen 2013-07-23 21:53:01 -07:00
parent 1784972af7
commit d28f1fff56
1 changed files with 4 additions and 5 deletions

View File

@ -718,10 +718,10 @@ checkConstantIfs _ = return ()
prop_checkNoaryWasBinary = verify checkNoaryWasBinary "[[ a==$foo ]]" prop_checkNoaryWasBinary = verify checkNoaryWasBinary "[[ a==$foo ]]"
prop_checkNoaryWasBinary2 = verify checkNoaryWasBinary "[ $foo=3 ]" prop_checkNoaryWasBinary2 = verify checkNoaryWasBinary "[ $foo=3 ]"
prop_checkNoaryWasBinary3 = verify checkNoaryWasBinary "[ foo!=3 ]" prop_checkNoaryWasBinary3 = verify checkNoaryWasBinary "[ $foo!=3 ]"
checkNoaryWasBinary (TC_Noary _ _ t@(T_NormalWord id l)) = do checkNoaryWasBinary (TC_Noary _ _ t@(T_NormalWord id l)) | not $ isConstant t = do
let str = concat $ deadSimple t 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 () checkNoaryWasBinary _ = return ()
prop_checkConstantNoary = verify checkConstantNoary "[[ '$(foo)' ]]" prop_checkConstantNoary = verify checkConstantNoary "[[ '$(foo)' ]]"
@ -729,8 +729,7 @@ prop_checkConstantNoary2 = verify checkConstantNoary "[ \"-f lol\" ]"
prop_checkConstantNoary3 = verify checkConstantNoary "[[ cmd ]]" prop_checkConstantNoary3 = verify checkConstantNoary "[[ cmd ]]"
prop_checkConstantNoary4 = verify checkConstantNoary "[[ ! cmd ]]" prop_checkConstantNoary4 = verify checkConstantNoary "[[ ! cmd ]]"
checkConstantNoary (TC_Noary _ _ t@(T_NormalWord id _)) | isConstant t = do 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." err id $ "This expression is constant. Did you forget a $ somewhere?"
else "Always true, just checks the non-emptyness of the literal word."
checkConstantNoary _ = return () checkConstantNoary _ = return ()
prop_checkBraceExpansionVars = verify checkBraceExpansionVars "echo {1..$n}" prop_checkBraceExpansionVars = verify checkBraceExpansionVars "echo {1..$n}"