diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-07-08 11:02:43 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-09 08:47:22 -0400 |
commit | 2d4cdfda6a7f068fe4a1cf586ccb2866b35e0250 (patch) | |
tree | 9b308c925d387cada0126db89850a9820ab9307c /ghc | |
parent | 60fabd7eb3e3450636673d818075da19074ddad0 (diff) | |
download | haskell-2d4cdfda6a7f068fe4a1cf586ccb2866b35e0250.tar.gz |
Avoid unsafePerformIO for getProgName
getProgName was used to append the name of the program (e.g. "ghc") to
printed error messages in the Show instance of GhcException. It doesn't
belong here as GHCi and GHC API users may want to override this behavior
by setting a different error handler. So we now call it in the
defaultErrorHandler instead.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/Main.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index bda5cd9ef9..ad975d1840 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -762,11 +762,13 @@ showUsage ghci dflags = do let usage_path = if ghci then ghciUsagePath dflags else ghcUsagePath dflags usage <- readFile usage_path - dump usage + progName <- getProgName + dump progName usage where - dump "" = return () - dump ('$':'$':s) = putStr progName >> dump s - dump (c:s) = putChar c >> dump s + dump progName xs = case xs of + "" -> return () + '$':'$':s -> putStr progName >> dump progName s + c:s -> putChar c >> dump progName s dumpFinalStats :: Logger -> IO () dumpFinalStats logger = do |