Allow `#inline comments` without SC2046.

This commit is contained in:
Vidar Holen 2016-09-05 12:38:35 -07:00
parent 47a7065a7a
commit 5a46eeb09a
1 changed files with 6 additions and 5 deletions

View File

@ -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 =