aboutsummaryrefslogtreecommitdiff
path: root/Setup.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-07-06 13:38:46 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-07-06 13:38:46 -0700
commite042f697a4557b21789cb7404745746aea2535b4 (patch)
treea2d5c734051be0937b2d0ac24d01ef41ded1bcda /Setup.hs
parent48cd7747149dcb7d4149fb4524066afe380a8567 (diff)
downloadpandoc-e042f697a4557b21789cb7404745746aea2535b4.tar.gz
Setup.hs: better version detection in older hsb2hs.
If it returns an error with input `--version`, recover gracefully.
Diffstat (limited to 'Setup.hs')
-rw-r--r--Setup.hs18
1 files changed, 11 insertions, 7 deletions
diff --git a/Setup.hs b/Setup.hs
index a328c75a7..312e1cf47 100644
--- a/Setup.hs
+++ b/Setup.hs
@@ -32,6 +32,7 @@ import Data.Version
import System.Process (readProcess)
import Text.ParserCombinators.ReadP (readP_to_S, skipSpaces, eof)
import Control.Monad (when)
+import qualified Control.Exception as E
main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks {
@@ -44,13 +45,16 @@ main = defaultMainWithHooks $ simpleUserHooks {
findHsb2hsVersion :: Verbosity -> FilePath -> IO (Maybe Version)
findHsb2hsVersion verb fp = do
- outp <- readProcess fp ["--version"] ""
- case readP_to_S (do v <- parseVersion
- skipSpaces
- eof
- return v) outp of
- ((v,""):_) -> return (Just v)
- _ -> return Nothing
+ let handleExitFailure :: IOError -> IO (Maybe Version)
+ handleExitFailure _ = return Nothing
+ E.handle handleExitFailure $ do
+ outp <- readProcess fp ["--version"] ""
+ case readP_to_S (do v <- parseVersion
+ skipSpaces
+ eof
+ return v) outp of
+ ((v,""):_) -> return (Just v)
+ _ -> return Nothing
ppBlobSuffixHandler :: PPSuffixHandler
ppBlobSuffixHandler = ("hsb", \_ lbi ->