From 42abcb7ae2a68b283f3592b13736d988bcfb51e5 Mon Sep 17 00:00:00 2001 From: "Joseph C. Sible" Date: Sun, 9 Feb 2020 23:12:27 -0500 Subject: [PATCH] Simplify shellFromFilename --- src/ShellCheck/Checker.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ShellCheck/Checker.hs b/src/ShellCheck/Checker.hs index 6370f75..60280ec 100644 --- a/src/ShellCheck/Checker.hs +++ b/src/ShellCheck/Checker.hs @@ -48,7 +48,7 @@ tokenToPosition startMap t = fromMaybe fail $ do where fail = error "Internal shellcheck error: id doesn't exist. Please report!" -shellFromFilename filename = foldl mplus Nothing candidates +shellFromFilename filename = listToMaybe candidates where shellExtensions = [(".ksh", Ksh) ,(".bash", Bash) @@ -57,7 +57,7 @@ shellFromFilename filename = foldl mplus Nothing candidates -- The `.sh` is too generic to determine the shell: -- We fallback to Bash in this case and emit SC2148 if there is no shebang candidates = - map (\(ext,sh) -> if ext `isSuffixOf` filename then Just sh else Nothing) shellExtensions + [sh | (ext,sh) <- shellExtensions, ext `isSuffixOf` filename] checkScript :: Monad m => SystemInterface m -> CheckSpec -> m CheckResult checkScript sys spec = do