From 38c5c6f84730a5bd3baf2c4e9647a66491f00a84 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Thu, 8 Nov 2012 21:55:24 -0800 Subject: [PATCH] Added warning for {1..$N} --- ShellCheck/Analytics.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index c7a9157..ba29b5b 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -34,6 +34,7 @@ basicChecks = [ ,checkUnquotedZN ,checkNumberComparisons ,checkNoaryWasBinary + ,checkBraceExpansionVars ] modifyMap = modify @@ -233,6 +234,11 @@ checkNoaryWasBinary (TC_Noary _ _ t@(T_NormalWord id l)) = do when ('=' `elem` str) $ addNoteFor id $ Note ErrorC $ "Always true because you didn't put spaces around the =" checkNoaryWasBinary _ = return () +prop_checkBraceExpansionVars = verify checkBraceExpansionVars "echo {1..$n}" +checkBraceExpansionVars (T_BraceExpansion id s) | '$' `elem` s = + addNoteFor id $ Note WarningC $ "You can't use variables in brace expansions." +checkBraceExpansionVars _ = return () + allModifiedVariables t = snd $ runState (doAnalysis (\x -> modify $ (++) (getModifiedVariables x)) t) [] --- Subshell detection