diff options
Diffstat (limited to 'Utility.hs')
-rw-r--r-- | Utility.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Utility.hs b/Utility.hs index 788dc4103..451b1b44f 100644 --- a/Utility.hs +++ b/Utility.hs @@ -15,7 +15,8 @@ module Utility ( dirContains, dirContents, myHomeDir, - catchBool + catchBool, + inPath ) where import IO (bracket) @@ -94,3 +95,12 @@ myHomeDir = do {- Catches IO errors and returns a Bool -} catchBool :: IO Bool -> IO Bool catchBool = flip catch (const $ return False) + +{- Checks if a command is available in PATH. -} +inPath :: String -> IO Bool +inPath command = search =<< getSearchPath + where + search [] = return False + search (d:ds) = do + e <- doesFileExist $ d </> command + if e then return True else search ds |