Fix ghc-modi not exiting cleanly

This commit is contained in:
Daniel Gröber 2015-08-18 04:50:19 +02:00
parent 97c632fbd7
commit cdc74e059c
1 changed files with 5 additions and 2 deletions

View File

@ -23,9 +23,8 @@ import System.FilePath ((</>))
import System.Directory (setCurrentDirectory, getAppUserDataDirectory, import System.Directory (setCurrentDirectory, getAppUserDataDirectory,
removeDirectoryRecursive) removeDirectoryRecursive)
import System.Environment (getArgs) import System.Environment (getArgs)
import System.Exit (exitFailure)
import System.IO (stdout, hSetEncoding, utf8, hFlush) import System.IO (stdout, hSetEncoding, utf8, hFlush)
import System.Exit (exitSuccess) import System.Exit
import Text.PrettyPrint import Text.PrettyPrint
import Prelude import Prelude
@ -373,6 +372,8 @@ data InteractiveOptions = InteractiveOptions {
handler :: IOish m => GhcModT m a -> GhcModT m a handler :: IOish m => GhcModT m a -> GhcModT m a
handler = flip gcatches $ handler = flip gcatches $
[ GHandler $ \(FatalError msg) -> exitError msg [ GHandler $ \(FatalError msg) -> exitError msg
, GHandler $ \e@(ExitSuccess) -> throw e
, GHandler $ \e@(ExitFailure _) -> throw e
, GHandler $ \(InvalidCommandLine e) -> do , GHandler $ \(InvalidCommandLine e) -> do
case e of case e of
Left cmd -> Left cmd ->
@ -494,6 +495,8 @@ legacyInteractiveLoop symdbreq world = do
where where
interactiveHandlers = interactiveHandlers =
[ GHandler $ \e@(FatalError _) -> throw e [ GHandler $ \e@(FatalError _) -> throw e
, GHandler $ \e@(ExitSuccess) -> throw e
, GHandler $ \e@(ExitFailure _) -> throw e
, GHandler $ \(SomeException e) -> gmErrStrLn (show e) >> return "" , GHandler $ \(SomeException e) -> gmErrStrLn (show e) >> return ""
] ]