Remove unnecessary use of Maybe from shellFor

This commit is contained in:
Joseph C. Sible 2020-12-28 16:22:53 -05:00
parent bd3299edd3
commit 35033a9f2f
1 changed files with 3 additions and 3 deletions

View File

@ -258,9 +258,9 @@ determineShell fallbackShell t = fromMaybe Bash $
executableFromShebang :: String -> String
executableFromShebang = shellFor
where
shellFor s | "/env " `isInfixOf` s = fromMaybe "" $ do
[flag, shell] <- matchRegex re s
return shell
shellFor s | "/env " `isInfixOf` s = case matchRegex re s of
Just [flag, shell] -> shell
_ -> ""
shellFor s | ' ' `elem` s = shellFor $ takeWhile (/= ' ') s
shellFor s = reverse . takeWhile (/= '/') . reverse $ s
re = mkRegex "/env +(-S|--split-string=?)? *([^ ]*)"