From 8055b6f9c57ffa0cc1b20f9301bd9a5445e6503d Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Tue, 9 Jul 2013 09:26:48 -0700 Subject: [PATCH] Fixed warning for trap '$VAR' --- ShellCheck/Analytics.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index f8db88b..4ad3bf7 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -592,12 +592,14 @@ prop_checkSingleQuotedVariables3a= verifyTree checkSingleQuotedVariables "sed 's prop_checkSingleQuotedVariables3b= verifyTree checkSingleQuotedVariables "sed 's/$(echo cow)/bar/'" prop_checkSingleQuotedVariables3c= verifyTree checkSingleQuotedVariables "sed 's/$((1+foo))/bar/'" prop_checkSingleQuotedVariables4 = verifyNotTree checkSingleQuotedVariables "awk '{print $1}'" +prop_checkSingleQuotedVariables5 = verifyNotTree checkSingleQuotedVariables "trap 'echo $SECONDS' EXIT" checkSingleQuotedVariables t@(T_SingleQuoted id s) parents = case matchRegex checkSingleQuotedVariablesRe s of Just [] -> unless (probablyOk t) $ info id $ "Expressions don't expand in single quotes, use double quotes for that." _ -> return () where - probablyOk t = isParamTo parents "awk" t + probablyOk t = + isParamTo parents "awk" t || isParamTo parents "trap" t checkSingleQuotedVariables _ _ = return () checkSingleQuotedVariablesRe = mkRegex "\\$[{(0-9a-zA-Z_]"