diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-02-28 16:59:52 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-02-28 16:59:52 -0400 |
commit | a35208c5df555006431a66436288ce156af4fdb9 (patch) | |
tree | 5c07d4b504f56f7f1f58a9c186a0166be67b87d8 | |
parent | 037834477ef6ac97f9a50e02a529a4f6d2fc7b45 (diff) |
make programPath return FilePath not Maybe FilePath
Looking at the few current callers, it's ok to have programPath throw an
exception, in the unusual case where it cannot find git-annex.
-rw-r--r-- | Annex/Path.hs | 9 | ||||
-rw-r--r-- | Assistant/Threads/UpgradeWatcher.hs | 3 | ||||
-rw-r--r-- | Config/Files.hs | 7 |
3 files changed, 11 insertions, 8 deletions
diff --git a/Annex/Path.hs b/Annex/Path.hs index 6186a887b..ac4e77645 100644 --- a/Annex/Path.hs +++ b/Annex/Path.hs @@ -17,9 +17,10 @@ import System.Environment - - getExecutablePath is available since ghc 7.4.2. On OSs it supports - well, it returns the complete path to the program. But, on other OSs, - - it might return just the basename. + - it might return just the basename. Fall back to reading the programFile, + - or searching for the command name in PATH. -} -programPath :: IO (Maybe FilePath) +programPath :: IO FilePath programPath = do #if MIN_VERSION_base(4,6,0) exe <- getExecutablePath @@ -29,6 +30,4 @@ programPath = do #else p <- readProgramFile #endif - -- In case readProgramFile returned just the command name, - -- fall back to finding it in PATH. - searchPath p + maybe cannotFindProgram return =<< searchPath p diff --git a/Assistant/Threads/UpgradeWatcher.hs b/Assistant/Threads/UpgradeWatcher.hs index e779c8e54..952db1f13 100644 --- a/Assistant/Threads/UpgradeWatcher.hs +++ b/Assistant/Threads/UpgradeWatcher.hs @@ -36,8 +36,7 @@ upgradeWatcherThread urlrenderer = namedThread "UpgradeWatcher" $ do showSuccessfulUpgrade urlrenderer go =<< liftIO upgradeFlagFile where - go Nothing = debug [ "cannot determine program path" ] - go (Just flagfile) = do + go flagfile = do mvar <- liftIO $ newMVar InStartupScan changed <- Just <$> asIO2 (changedFile urlrenderer mvar flagfile) let hooks = mkWatchHooks diff --git a/Config/Files.hs b/Config/Files.hs index b503a5443..d2b2f6a51 100644 --- a/Config/Files.hs +++ b/Config/Files.hs @@ -62,8 +62,13 @@ readProgramFile = do ( return p , ifM (inPath cmd) ( return cmd - , error $ "cannot find git-annex program in PATH or in the location listed in " ++ programfile + , cannotFindProgram ) ) where cmd = "git-annex" + +cannotFindProgram :: IO a +cannotFindProgram = do + f <- programFile + error $ "cannot find git-annex program in PATH or in the location listed in " ++ f |