Skip to content

Commit

Permalink
Merge pull request koalaman#1865 from josephcsible/patch-1
Browse files Browse the repository at this point in the history
Use headOrDefault instead of fromMaybe and listToMaybe
  • Loading branch information
koalaman authored Mar 15, 2020
2 parents c43b19f + 45a67e7 commit d28c8f8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/ShellCheck/AnalyzerLib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ determineShell fallbackShell t = fromMaybe Bash $
getCandidate :: Token -> String
getCandidate t@T_Script {} = fromShebang t
getCandidate (T_Annotation _ annotations s) =
fromMaybe (fromShebang s) $
listToMaybe [s | ShellOverride s <- annotations]
headOrDefault (fromShebang s) [s | ShellOverride s <- annotations]
fromShebang (T_Script _ (T_Literal _ s) _) = executableFromShebang s

-- Given a string like "/bin/bash" or "/usr/bin/env dash",
Expand Down Expand Up @@ -852,7 +851,7 @@ getBracedReference s = fromMaybe s $
prop_getBracedModifier1 = getBracedModifier "foo:bar:baz" == ":bar:baz"
prop_getBracedModifier2 = getBracedModifier "!var:-foo" == ":-foo"
prop_getBracedModifier3 = getBracedModifier "foo[bar]" == "[bar]"
getBracedModifier s = fromMaybe "" . listToMaybe $ do
getBracedModifier s = headOrDefault "" $ do
let var = getBracedReference s
a <- dropModifier s
dropPrefix var a
Expand Down

0 comments on commit d28c8f8

Please sign in to comment.