--- This version is for the GHC command-line option -e. The only difference
--- from runCommand is that it catches the ExitException exception and
--- exits, rather than printing out the exception.
-runCommandEval :: String -> GHCi Bool
-runCommandEval c = ghciHandle handleEval (doCommand c)
- where
- handleEval (ExitException code) = io (exitWith code)
- handleEval e = do handler e
- io (exitWith (ExitFailure 1))
-
- doCommand (':' : command) = specialCommand command
- doCommand stmt
- = do r <- runStmt stmt GHC.RunToCompletion
- case r of
- False -> io (exitWith (ExitFailure 1))
- -- failure to run the command causes exit(1) for ghc -e.
- _ -> return True
-