From 8f105074feebda422e4242d04bb4afdf1e0431cf Mon Sep 17 00:00:00 2001 From: "Joseph C. Sible" Date: Sun, 5 Apr 2020 19:01:56 -0400 Subject: [PATCH] Simplify getCommandNameAndToken --- src/ShellCheck/ASTLib.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ShellCheck/ASTLib.hs b/src/ShellCheck/ASTLib.hs index 2b40705..05c3838 100644 --- a/src/ShellCheck/ASTLib.hs +++ b/src/ShellCheck/ASTLib.hs @@ -317,13 +317,11 @@ getCommandNameAndToken :: Token -> (Maybe String, Token) getCommandNameAndToken t = fromMaybe (Nothing, t) $ do (T_SimpleCommand _ _ (w:rest)) <- getCommand t s <- getLiteralString w - if "busybox" `isSuffixOf` s || "builtin" == s - then - case rest of - (applet:_) -> return (getLiteralString applet, applet) - _ -> return (Just s, w) - else - return (Just s, w) + return $ case rest of + (applet:_) | "busybox" `isSuffixOf` s || "builtin" == s -> + (getLiteralString applet, applet) + _ -> + (Just s, w) -- If a command substitution is a single command, get its name.