From 5a46eeb09a580e9f9424ebaabe5193e236aca9f6 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Mon, 5 Sep 2016 12:38:35 -0700 Subject: [PATCH] Allow `#inline comments` without SC2046. --- ShellCheck/Analytics.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index 6ccc3f3..af1a935 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -774,16 +774,17 @@ prop_checkUnquotedExpansions5 = verifyNot checkUnquotedExpansions "for f in $(cm prop_checkUnquotedExpansions6 = verifyNot checkUnquotedExpansions "$(cmd)" prop_checkUnquotedExpansions7 = verifyNot checkUnquotedExpansions "cat << foo\n$(ls)\nfoo" prop_checkUnquotedExpansions8 = verifyNot checkUnquotedExpansions "set -- $(seq 1 4)" +prop_checkUnquotedExpansions9 = verifyNot checkUnquotedExpansions "echo foo `# inline comment`" checkUnquotedExpansions params = check where - check t@(T_DollarExpansion _ _) = examine t - check t@(T_Backticked _ _) = examine t - check t@(T_DollarBraceCommandExpansion _ _) = examine t + check t@(T_DollarExpansion _ c) = examine t c + check t@(T_Backticked _ c) = examine t c + check t@(T_DollarBraceCommandExpansion _ c) = examine t c check _ = return () tree = parentMap params - examine t = - unless (shouldBeSplit t || isQuoteFree tree t || usedAsCommandName tree t) $ + examine t contents = + unless (null contents || shouldBeSplit t || isQuoteFree tree t || usedAsCommandName tree t) $ warn (getId t) 2046 "Quote this to prevent word splitting." shouldBeSplit t =