Rename Unquotable to QuoteFree

This commit is contained in:
Vidar Holen 2014-03-22 10:27:59 -07:00
parent 60aafae21d
commit 50db49e2fb
1 changed files with 32 additions and 32 deletions

View File

@ -692,7 +692,7 @@ checkUnquotedExpansions params t =
check _ = return () check _ = return ()
tree = parentMap params tree = parentMap params
examine t = examine t =
unless (inUnquotableContext tree t || usedAsCommandName tree t) $ unless (isQuoteFree tree t || usedAsCommandName tree t) $
warn (getId t) 2046 "Quote this to prevent word splitting." warn (getId t) 2046 "Quote this to prevent word splitting."
@ -1094,36 +1094,36 @@ getTokenMap t =
f t = modify (Map.insert (getId t) t) f t = modify (Map.insert (getId t) t)
-- Should this entity be quoted? -- Is this node self quoting?
inUnquotableContext tree t = isQuoteFree tree t =
(isUnquotable t == Just True) || (isQuoteFreeElement t == Just True) ||
(head $ (mapMaybe isUnquotableContext $ drop 1 $ getPath tree t) ++ [False]) (head $ (mapMaybe isQuoteFreeContext $ drop 1 $ getPath tree t) ++ [False])
where
-- Is this node self-quoting in itself?
isQuoteFreeElement t =
case t of
T_Assignment {} -> return True
_ -> Nothing
-- A usage that in itself doesn't require quotes -- Are any subnodes inherently self-quoting?
isUnquotable t = isQuoteFreeContext t =
case t of case t of
T_Assignment {} -> return True TC_Noary _ DoubleBracket _ -> return True
_ -> Nothing TC_Unary _ DoubleBracket _ _ -> return True
TC_Binary _ DoubleBracket _ _ _ -> return True
-- A usage in which any subnode doesn't require quotes TA_Unary _ _ _ -> return True
isUnquotableContext t = TA_Binary _ _ _ _ -> return True
case t of TA_Trinary _ _ _ _ -> return True
TC_Noary _ DoubleBracket _ -> return True TA_Expansion _ _ -> return True
TC_Unary _ DoubleBracket _ _ -> return True T_Assignment {} -> return True
TC_Binary _ DoubleBracket _ _ _ -> return True T_Redirecting _ _ _ -> return $
TA_Unary _ _ _ -> return True any (isCommand t) ["local", "declare", "typeset", "export"]
TA_Binary _ _ _ _ -> return True T_DoubleQuoted _ _ -> return True
TA_Trinary _ _ _ _ -> return True T_CaseExpression _ _ _ -> return True
TA_Expansion _ _ -> return True T_HereDoc _ _ _ _ _ -> return True
T_Assignment {} -> return True T_DollarBraced {} -> return True
T_Redirecting _ _ _ -> return $ T_ForIn _ _ _ _ -> return True -- Pragmatically assume it's desirable here
any (isCommand t) ["local", "declare", "typeset", "export"] _ -> Nothing
T_DoubleQuoted _ _ -> return True
T_CaseExpression _ _ _ -> return True
T_HereDoc _ _ _ _ _ -> return True
T_DollarBraced {} -> return True
T_ForIn _ _ _ _ -> return True -- Pragmatically assume it's desirable here
_ -> Nothing
isParamTo tree cmd t = isParamTo tree cmd t =
go t go t
@ -1883,7 +1883,7 @@ checkSpacefulness params t =
if spaced if spaced
&& (not $ "@" `isPrefixOf` name) -- There's another warning for this && (not $ "@" `isPrefixOf` name) -- There's another warning for this
&& (not $ isCounting token) && (not $ isCounting token)
&& (not $ inUnquotableContext parents token) && (not $ isQuoteFree parents token)
&& (not $ usedAsCommandName parents token) && (not $ usedAsCommandName parents token)
then return [(Note (getId token) InfoC 2086 warning)] then return [(Note (getId token) InfoC 2086 warning)]
else return [] else return []
@ -1972,7 +1972,7 @@ checkQuotesInLiterals params t =
assignment <- getQuotes name assignment <- getQuotes name
if isJust assignment if isJust assignment
&& not (isParamTo parents "eval" expr) && not (isParamTo parents "eval" expr)
&& not (inUnquotableContext parents expr) && not (isQuoteFree parents expr)
then return [ then return [
Note (fromJust assignment)WarningC 2089 $ Note (fromJust assignment)WarningC 2089 $
"Quotes/backslashes will be treated literally. Use an array.", "Quotes/backslashes will be treated literally. Use an array.",