summaryrefslogtreecommitdiff
path: root/Utility/Path.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-14 15:52:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-14 16:07:59 -0400
commit3780a5eb0a01e3d31fc0de2410f7b01518710a0e (patch)
tree0b187086ee7cb6ed6dd1c49b4dd0871c856a27cd /Utility/Path.hs
parentd6adaf499124c11e3d79252821ef400d2a87b155 (diff)
move thirdparty program installation for standalone bundle into haskell program
This allows it to use Build.SysConfig to always install the programs configure detected. Amoung other fixes, this ensures the right uuid generator and checksum programs are installed. I also cleaned up the handling of lsof's path; configure now checks for it in PATH, but falls back to looking for it in sbin directories.
Diffstat (limited to 'Utility/Path.hs')
-rw-r--r--Utility/Path.hs20
1 files changed, 17 insertions, 3 deletions
diff --git a/Utility/Path.hs b/Utility/Path.hs
index 4bab297da..ba836d9b6 100644
--- a/Utility/Path.hs
+++ b/Utility/Path.hs
@@ -132,11 +132,25 @@ relHome path = do
then "~/" ++ relPathDirToFile home path
else path
-{- Checks if a command is available in PATH. -}
+{- Checks if a command is available in PATH.
+ -
+ - The command may be fully-qualified, in which case, this succeeds as
+ - long as it exists. -}
inPath :: String -> IO Bool
-inPath command = getSearchPath >>= anyM indir
+inPath command = isJust <$> searchPath command
+
+{- Finds a command in PATH and returns the full path to it.
+ -
+ - The command may be fully qualified already, in which case it will
+ - be returned if it exists.
+ -}
+searchPath :: String -> IO (Maybe FilePath)
+searchPath command
+ | isAbsolute command = check command
+ | otherwise = getSearchPath >>= getM indir
where
- indir d = doesFileExist $ d </> command
+ indir d = check $ d </> command
+ check f = ifM (doesFileExist f) ( return (Just f), return Nothing )
{- Checks if a filename is a unix dotfile. All files inside dotdirs
- count as dotfiles. -}