Merge pull request #1873 from josephcsible/checkwhilereadpitfalls

Simplify checkWhileReadPitfalls
This commit is contained in:
Vidar Holen 2020-03-31 19:10:53 -07:00 committed by GitHub
commit c60323fb25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -2340,18 +2340,18 @@ checkWhileReadPitfalls params (T_WhileExpression id [command] contents)
let plaintext = oversimplify cmd
in headOrDefault "" plaintext == "read"
&& ("-u" `notElem` plaintext)
&& all (not . stdinRedirect) redirs
&& not (any stdinRedirect redirs)
isStdinReadCommand _ = False
checkMuncher :: Token -> Writer [TokenComment] ()
checkMuncher (T_Pipeline _ _ (T_Redirecting _ redirs cmd:_)) = do
-- Check command substitutions regardless of the command
sequence_ $ do
(T_SimpleCommand _ vars args) <- Just cmd
let words = concat $ concatMap getCommandSequences $ concatMap getWords $ vars ++ args
return $ mapM_ checkMuncher words
case cmd of
T_SimpleCommand _ vars args ->
mapM_ checkMuncher $ concat $ concatMap getCommandSequences $ concatMap getWords $ vars ++ args
_ -> return ()
when (not $ any stdinRedirect redirs) $ do
unless (any stdinRedirect redirs) $ do
-- Recurse into ifs/loops/groups/etc if this doesn't redirect
mapM_ checkMuncher $ concat $ getCommandSequences cmd