summaryrefslogtreecommitdiff
path: root/Config
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-20 17:42:40 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-20 17:42:40 -0400
commite445b634f9ad90952478de669bc19bd6819d601a (patch)
treeebde467c7261f4c61d838bf95d3633e1eb95b84e /Config
parentbd02fe9ffd3222f5bcee7e173dbd0e5caa1e955c (diff)
Detect bad content in ~/.config/git-annex/program and look in PATH instead.
Diffstat (limited to 'Config')
-rw-r--r--Config/Files.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/Config/Files.hs b/Config/Files.hs
index 6504d1f6d..23564c2df 100644
--- a/Config/Files.hs
+++ b/Config/Files.hs
@@ -46,7 +46,7 @@ removeAutoStartFile path = modifyAutoStartFile $
filter (not . equalFilePath path)
{- The path to git-annex is written here; which is useful when cabal
- - has installed it to some aweful non-PATH location. -}
+ - has installed it to some awful non-PATH location. -}
programFile :: IO FilePath
programFile = userConfigFile "program"
@@ -54,7 +54,14 @@ programFile = userConfigFile "program"
readProgramFile :: IO FilePath
readProgramFile = do
programfile <- programFile
- catchDefaultIO cmd $
+ p <- catchDefaultIO cmd $
fromMaybe cmd . headMaybe . lines <$> readFile programfile
+ ifM (inPath p)
+ ( return p
+ , ifM (inPath cmd)
+ ( return cmd
+ , error $ "cannot find git-annex program in PATH or in the location listed in " ++ programfile
+ )
+ )
where
cmd = "git-annex"