File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -1763,6 +1763,7 @@ prop_checkInexplicablyUnquoted6 = verifyNot checkInexplicablyUnquoted "\"$dir\"s
1763
1763
prop_checkInexplicablyUnquoted7 = verifyNot checkInexplicablyUnquoted " ${dir/\" foo\" /\" bar\" }"
1764
1764
prop_checkInexplicablyUnquoted8 = verifyNot checkInexplicablyUnquoted " 'foo'\\\n 'bar'"
1765
1765
prop_checkInexplicablyUnquoted9 = verifyNot checkInexplicablyUnquoted " [[ $x =~ \" foo\" (\" bar\" |\" baz\" ) ]]"
1766
+ prop_checkInexplicablyUnquoted10 = verifyNot checkInexplicablyUnquoted " cmd ${x+--name=\" $x\" --output=\" $x.out\" }"
1766
1767
checkInexplicablyUnquoted params (T_NormalWord id tokens) = mapM_ check (tails tokens)
1767
1768
where
1768
1769
check (T_SingleQuoted _ _: T_Literal id str: _)
@@ -1774,19 +1775,20 @@ checkInexplicablyUnquoted params (T_NormalWord id tokens) = mapM_ check (tails t
1774
1775
T_DollarExpansion id _ -> warnAboutExpansion id
1775
1776
T_DollarBraced id _ _ -> warnAboutExpansion id
1776
1777
T_Literal id s
1777
- | not (quotesSingleThing a && quotesSingleThing b || isRegex (getPath (parentMap params) trapped)) ->
1778
+ | not (quotesSingleThing a && quotesSingleThing b || isSpecial (getPath (parentMap params) trapped)) ->
1778
1779
warnAboutLiteral id
1779
1780
_ -> return ()
1780
1781
1781
1782
check _ = return ()
1782
1783
1783
1784
-- Regexes for [[ .. =~ re ]] are parsed with metacharacters like ()| as unquoted
1784
- -- literals, so avoid overtriggering on these.
1785
- isRegex t =
1785
+ -- literals. The same is true for ${x+"foo" "bar"}. Avoid overtriggering on these.
1786
+ isSpecial t =
1786
1787
case t of
1787
1788
(T_Redirecting {} : _) -> False
1789
+ T_DollarBraced {} : _ -> True
1788
1790
(a: (TC_Binary _ _ " =~" lhs rhs): rest) -> getId a == getId rhs
1789
- _: rest -> isRegex rest
1791
+ _: rest -> isSpecial rest
1790
1792
_ -> False
1791
1793
1792
1794
-- If the surrounding quotes quote single things, like "$foo"_and_then_some_"$stuff",
You can’t perform that action at this time.
0 commit comments