From 77a3e3b331ce5ec23010bfc0d483631448958363 Mon Sep 17 00:00:00 2001 From: Vidar Holen <spam@vidarholen.net> Date: Tue, 27 Nov 2012 20:40:13 -0800 Subject: [PATCH] Fixed incorrectly calling [ -z $foo ] a tautology. --- ShellCheck/Analytics.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index 9263f1a..13a058c 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -50,7 +50,7 @@ basicChecks = [ ,checkUnquotedDollarAt ,checkStderrRedirect ,checkSingleQuotedVariables - ,checkUnquotedZN + ,checkUnquotedN ,checkNumberComparisons ,checkNoaryWasBinary ,checkBraceExpansionVars @@ -310,12 +310,12 @@ checkSingleQuotedVariables _ = return () checkSingleQuotedVariablesRe = mkRegex "(\\$[0-9a-zA-Z_]+)" -prop_checkUnquotedZN = verify checkUnquotedZN "if [ -z $foo ]; then echo cow; fi" -prop_checkUnquotedZN2 = verify checkUnquotedZN "[ -n $cow ]" -prop_checkUnquotedZN3 = verifyNot checkUnquotedZN "[[ -z $foo ]] && echo cow" -checkUnquotedZN (T_Condition _ SingleBracket (TC_Unary _ SingleBracket op (T_NormalWord id [t]))) | ( op == "-z" || op == "-n" ) && willSplit t = +prop_checkUnquotedN = verify checkUnquotedN "if [ -n $foo ]; then echo cow; fi" +prop_checkUnquotedN2 = verify checkUnquotedN "[ -n $cow ]" +prop_checkUnquotedN3 = verifyNot checkUnquotedN "[[ -n $foo ]] && echo cow" +checkUnquotedN (T_Condition _ SingleBracket (TC_Unary _ SingleBracket "-n" (T_NormalWord id [t]))) | willSplit t = err id "Always true because you failed to quote. Use [[ ]] instead." -checkUnquotedZN _ = return () +checkUnquotedN _ = return () prop_checkNumberComparisons1 = verify checkNumberComparisons "[[ $foo < 3 ]]" prop_checkNumberComparisons2 = verify checkNumberComparisons "[[ 0 >= $(cmd) ]]"