From ebf97a1e0f555e3f66475c07decffd87ba6556a7 Mon Sep 17 00:00:00 2001 From: Ng Zhi An Date: Tue, 20 Nov 2018 21:51:05 -0800 Subject: [PATCH] More warnings for unquoted unary tests Fixes #1353 Fixes #750 --- src/ShellCheck/Analytics.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 3002e3e..7489edc 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -876,8 +876,8 @@ prop_checkUnquotedN2 = verify checkUnquotedN "[ -n $cow ]" prop_checkUnquotedN3 = verifyNot checkUnquotedN "[[ -n $foo ]] && echo cow" prop_checkUnquotedN4 = verify checkUnquotedN "[ -n $cow -o -t 1 ]" prop_checkUnquotedN5 = verifyNot checkUnquotedN "[ -n \"$@\" ]" -checkUnquotedN _ (TC_Unary _ SingleBracket "-n" (T_NormalWord id [t])) | willSplit t = - err id 2070 "-n doesn't work with unquoted arguments. Quote or use [[ ]]." +checkUnquotedN _ (TC_Unary _ SingleBracket op (T_NormalWord id [t])) | willSplit t && op `elem` unaryTestOps = + err id 2070 (op ++ " doesn't work with unquoted arguments. Quote or use [[ ]].") checkUnquotedN _ _ = return () prop_checkNumberComparisons1 = verify checkNumberComparisons "[[ $foo < 3 ]]"