Commit b7cbc71d authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Catch exit exceptions as well as IO exceptions after running programs

We need to catch IO exceptions for things like "couldn't find the program",
but we also need to catch exit exceptions as Cabal uses them to signal
what the program returned.
parent f1e949d4
......@@ -141,7 +141,7 @@ import Distribution.Text
( Text(disp), display, simpleParse )
import Text.PrettyPrint.HughesPJ
( comma, punctuate, render, nest, sep )
import Distribution.Compat.Exception ( catchIO )
import Distribution.Compat.Exception ( catchExit, catchIO )
import Prelude hiding (catch)
......@@ -557,7 +557,8 @@ configurePkgconfigPackages verbosity pkg_descr conf
requirePkg dep@(Dependency (PackageName pkg) range) = do
version <- pkgconfig ["--modversion", pkg]
`catchIO` \_ -> die notFound
`catchIO` (\_ -> die notFound)
`catchExit` (\_ -> die notFound)
case simpleParse version of
Nothing -> die "parsing output of pkg-config --modversion failed"
Just v | not (withinRange v range) -> die (badVersion v)
......
......@@ -186,7 +186,8 @@ configure verbosity hcPath hcPkgPath conf = do
rawSystemProgramStdout verbosity ldProg
["-x", "-r", testofile, "-o", testofile']
return True
`catchIO` (\_ -> return False)
`catchIO` (\_ -> return False)
`catchExit` (\_ -> return False)
let conf''''' = updateProgram ldProg {
programArgs = if ldx then ["-x"] else []
} conf''''
......
......@@ -105,7 +105,7 @@ import Distribution.Verbosity
import System.Directory
( doesFileExist, findExecutable )
import Control.Monad (join, foldM)
import Distribution.Compat.Exception (catchIO)
import Distribution.Compat.Exception (catchExit, catchIO)
-- | Represents a program which can be configured.
data Program = Program {
......@@ -190,7 +190,8 @@ findProgramVersion :: ProgArg -- ^ version args
-> IO (Maybe Version)
findProgramVersion versionArg selectVersion verbosity path = do
str <- rawSystemStdout verbosity path [versionArg]
`catchIO` \_ -> return ""
`catchIO` (\_ -> return "")
`catchExit` (\_ -> return "")
let version :: Maybe Version
version = simpleParse (selectVersion str)
case version of
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment