Write getLiteralArgs with foldr and without fromMaybe or monads
This commit is contained in:
parent
01f4423465
commit
facf0d1e27
|
@ -289,10 +289,11 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
||||||
-- Get the literal options from a list of arguments,
|
-- Get the literal options from a list of arguments,
|
||||||
-- up until the first non-literal one
|
-- up until the first non-literal one
|
||||||
getLiteralArgs :: [Token] -> [(Id, String)]
|
getLiteralArgs :: [Token] -> [(Id, String)]
|
||||||
getLiteralArgs (first:rest) = fromMaybe [] $ do
|
getLiteralArgs = foldr go []
|
||||||
str <- getLiteralString first
|
where
|
||||||
return $ (getId first, str) : getLiteralArgs rest
|
go first rest = case getLiteralString first of
|
||||||
getLiteralArgs [] = []
|
Just str -> (getId first, str) : rest
|
||||||
|
Nothing -> []
|
||||||
|
|
||||||
-- Check a flag-option pair (such as -o errexit)
|
-- Check a flag-option pair (such as -o errexit)
|
||||||
checkOptions (flag@(fid,flag') : opt@(oid,opt') : rest)
|
checkOptions (flag@(fid,flag') : opt@(oid,opt') : rest)
|
||||||
|
|
Loading…
Reference in New Issue