[project @ 2000-10-13 10:26:38 by sewardj]
[ghc-hetmet.git] / ghc / compiler / main / ErrUtils.lhs
index 7e6e181..d6a64f3 100644 (file)
@@ -20,6 +20,9 @@ import Bag            ( Bag, bagToList, isEmptyBag )
 import SrcLoc          ( SrcLoc, noSrcLoc )
 import Util            ( sortLt )
 import Outputable
+import CmdLineOpts     ( DynFlags )
+
+import System          ( ExitCode(..), exitWith )
 import IO              ( hPutStr, stderr )
 \end{code}
 
@@ -83,11 +86,10 @@ pprBagOfWarnings bag_of_warns = pprBagOfErrors bag_of_warns
 
 \begin{code}
 ghcExit :: Int -> IO ()
-
 ghcExit val
-  = if val /= 0
-    then hPutStr stderr "\nCompilation had errors\n\n"
-    else return ()
+  | val == 0  = exitWith ExitSuccess
+  | otherwise = do hPutStr stderr "\nCompilation had errors\n\n"
+                  exitWith (ExitFailure val)
 \end{code}
 
 \begin{code}
@@ -97,10 +99,10 @@ doIfSet flag action | flag      = action
 \end{code}
 
 \begin{code}
-dumpIfSet :: Bool -> String -> SDoc -> IO ()
-dumpIfSet flag hdr doc
-  | not flag  = return ()
-  | otherwise = printDump dump
+dumpIfSet :: DynFlags -> (DynFlags -> Bool) -> String -> SDoc -> IO ()
+dumpIfSet dflags flag hdr doc
+  | not (flag dflags)  = return ()
+  | otherwise          = printDump dump
   where
     dump = vcat [text "", 
                 line <+> text hdr <+> line,