X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=257c219adf5120f127014b9712c9ab41e8520204;hb=8a45d6bb5426552fc6993fc4a1f391d0f3c77b8d;hp=d8f291c9eca33200a096d293167d65e32f5fa683;hpb=05afb7485eea44d6410139f8a20c94b6f66c46f2;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index d8f291c..257c219 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,6 +1,6 @@ {-# OPTIONS -#include "Linker.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.155 2003/07/02 14:59:07 simonpj Exp $ +-- $Id: InteractiveUI.hs,v 1.158 2003/08/27 12:29:21 simonmar Exp $ -- -- GHC Interactive User Interface -- @@ -45,8 +45,8 @@ import Panic hiding ( showException ) import Config #ifndef mingw32_HOST_OS -import System.Posix import DriverUtil( handle ) +import System.Posix #if __GLASGOW_HASKELL__ > 504 hiding (getEnv) #endif @@ -229,33 +229,31 @@ runGHCi paths dflags = do ghciHandle showException $ loadModule paths - -- enter the interactive loop -#if defined(mingw32_HOST_OS) - -- Always show prompt, since hIsTerminalDevice returns True for Consoles - -- only, which we may or may not be running under (cf. Emacs sub-shells.) - interactiveLoop True -#else + -- if verbosity is greater than 0, or we are connected to a + -- terminal, display the prompt in the interactive loop. is_tty <- io (hIsTerminalDevice stdin) - interactiveLoop is_tty -#endif + let show_prompt = verbosity dflags > 0 || is_tty + + -- enter the interactive loop + interactiveLoop is_tty show_prompt -- and finally, exit io $ do when (verbosity dflags > 0) $ putStrLn "Leaving GHCi." -interactiveLoop is_tty = do +interactiveLoop is_tty show_prompt = do -- Ignore ^C exceptions caught here ghciHandleDyn (\e -> case e of - Interrupted -> ghciUnblock (interactiveLoop is_tty) + Interrupted -> ghciUnblock (interactiveLoop is_tty show_prompt) _other -> return ()) $ do -- read commands from stdin #if HAVE_READLINE_HEADERS && HAVE_READLINE_LIBS if (is_tty) then readlineLoop - else fileLoop stdin False -- turn off prompt for non-TTY input + else fileLoop stdin show_prompt #else - fileLoop stdin is_tty + fileLoop stdin show_prompt #endif @@ -542,6 +540,14 @@ addModule files = do changeDirectory :: String -> GHCi () changeDirectory dir = do + state <- getGHCiState + when (targets state /= []) $ + io $ putStr "Warning: changing directory causes all loaded modules to be unloaded, \n\ + \because the search path has changed.\n" + dflags <- io getDynFlags + cmstate1 <- io (cmUnload (cmstate state) dflags) + setGHCiState state{ cmstate = cmstate1, targets = [] } + setContextAfterLoad [] dir <- expandPath dir io (setCurrentDirectory dir)