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