From facf0d1e27185861f7ede9ac1bd9803b440d6c77 Mon Sep 17 00:00:00 2001
From: "Joseph C. Sible" <josephcsible@users.noreply.github.com>
Date: Sun, 5 Apr 2020 21:59:27 -0400
Subject: [PATCH 1/2] Write getLiteralArgs with foldr and without fromMaybe or
 monads

---
 src/ShellCheck/Checks/ShellSupport.hs | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/ShellCheck/Checks/ShellSupport.hs b/src/ShellCheck/Checks/ShellSupport.hs
index 49d3212..de5f78c 100644
--- a/src/ShellCheck/Checks/ShellSupport.hs
+++ b/src/ShellCheck/Checks/ShellSupport.hs
@@ -289,10 +289,11 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
         -- Get the literal options from a list of arguments,
         -- up until the first non-literal one
         getLiteralArgs :: [Token] -> [(Id, String)]
-        getLiteralArgs (first:rest) = fromMaybe [] $ do
-            str <- getLiteralString first
-            return $ (getId first, str) : getLiteralArgs rest
-        getLiteralArgs [] = []
+        getLiteralArgs = foldr go []
+          where
+            go first rest = case getLiteralString first of
+                Just str -> (getId first, str) : rest
+                Nothing -> []
 
         -- Check a flag-option pair (such as -o errexit)
         checkOptions (flag@(fid,flag') : opt@(oid,opt') : rest)

From 8a6679fd8a12e365411d97918206f8dc1db5c1ec Mon Sep 17 00:00:00 2001
From: "Joseph C. Sible" <josephcsible@users.noreply.github.com>
Date: Sun, 5 Apr 2020 22:03:50 -0400
Subject: [PATCH 2/2] Remove unnecessary fromMaybe and when from bashism

---
 src/ShellCheck/Checks/ShellSupport.hs | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/ShellCheck/Checks/ShellSupport.hs b/src/ShellCheck/Checks/ShellSupport.hs
index de5f78c..054661a 100644
--- a/src/ShellCheck/Checks/ShellSupport.hs
+++ b/src/ShellCheck/Checks/ShellSupport.hs
@@ -391,11 +391,10 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
             ("unset", Just ["f", "v"]),
             ("wait", Just [])
             ]
-    bashism t@(T_SourceCommand id src _) =
-        let name = fromMaybe "" $ getCommandName src
-        in when (name == "source") $ warnMsg id "'source' in place of '.' is"
-    bashism (TA_Expansion _ (T_Literal id str : _)) | str `matches` radix =
-        when (str `matches` radix) $ warnMsg id "arithmetic base conversion is"
+    bashism t@(T_SourceCommand id src _)
+        | getCommandName src == Just "source" = warnMsg id "'source' in place of '.' is"
+    bashism (TA_Expansion _ (T_Literal id str : _))
+        | str `matches` radix = warnMsg id "arithmetic base conversion is"
       where
         radix = mkRegex "^[0-9]+#"
     bashism _ = return ()