From 9d5363377ef11ce0aaaf9b5b66f654f1e6a475d7 Mon Sep 17 00:00:00 2001 From: "Joseph C. Sible" Date: Mon, 16 Mar 2020 00:12:19 -0400 Subject: [PATCH] Simplify checkWhileReadPitfalls * Clean up usage of not * Use a case match instead of sequence_ and a do block --- src/ShellCheck/Analytics.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index f1c36fa..96e0750 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -2341,18 +2341,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