X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fghci%2FInteractiveUI.hs;h=e4439d65436222328a56cf0374e0c8b1c1a7f270;hb=be3eef905a72a5b21b5ec6fe51662e958249ca60;hp=a0c76ec52ef8f3279536d00221f101941eeef1fc;hpb=b70f35afc1c606dc85e6feb7da74be72411f58c1;p=ghc-hetmet.git diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index a0c76ec..e4439d6 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -263,10 +263,10 @@ findEditor = do getEnv "EDITOR" `IO.catch` \_ -> do #if mingw32_HOST_OS - win <- System.Win32.getWindowsDirectory - return (win `joinFileName` "notepad.exe") + win <- System.Win32.getWindowsDirectory + return (win "notepad.exe") #else - return "" + return "" #endif interactiveUI :: Session -> [(FilePath, Maybe Phase)] -> Maybe String -> IO () @@ -298,31 +298,31 @@ interactiveUI session srcs maybe_expr = do -- intended for the program, so unbuffer stdin. hSetBuffering stdin NoBuffering - -- initial context is just the Prelude - prel_mod <- GHC.findModule session (GHC.mkModuleName "Prelude") - (Just basePackageId) - GHC.setContext session [] [prel_mod] - #ifdef USE_READLINE - Readline.initialize - Readline.setAttemptedCompletionFunction (Just completeWord) - --Readline.parseAndBind "set show-all-if-ambiguous 1" + Readline.initialize + Readline.setAttemptedCompletionFunction (Just completeWord) + --Readline.parseAndBind "set show-all-if-ambiguous 1" - Readline.setBasicWordBreakCharacters word_break_chars - Readline.setCompleterWordBreakCharacters word_break_chars - Readline.setCompletionAppendCharacter Nothing + Readline.setBasicWordBreakCharacters word_break_chars + Readline.setCompleterWordBreakCharacters word_break_chars + Readline.setCompletionAppendCharacter Nothing #endif + -- initial context is just the Prelude + prel_mod <- GHC.findModule session (GHC.mkModuleName "Prelude") + (Just basePackageId) + GHC.setContext session [] [prel_mod] + default_editor <- findEditor startGHCi (runGHCi srcs maybe_expr) - GHCiState{ progname = "", - args = [], + GHCiState{ progname = "", + args = [], prompt = "%s> ", stop = "", - editor = default_editor, - session = session, - options = [], + editor = default_editor, + session = session, + options = [], prelude = prel_mod, break_ctr = 0, breaks = [], @@ -350,35 +350,35 @@ runGHCi paths maybe_expr = do dir_ok <- io (checkPerms ".") file_ok <- io (checkPerms file) when (dir_ok && file_ok) $ do - either_hdl <- io (IO.try (openFile "./.ghci" ReadMode)) - case either_hdl of - Left _e -> return () - Right hdl -> runCommands (fileLoop hdl False False) - + either_hdl <- io (IO.try (openFile "./.ghci" ReadMode)) + case either_hdl of + Left _e -> return () + Right hdl -> runCommands (fileLoop hdl False False) + when (read_dot_files) $ do -- Read in $HOME/.ghci either_dir <- io (IO.try getHomeDirectory) case either_dir of Left _e -> return () Right dir -> do - cwd <- io (getCurrentDirectory) - when (dir /= cwd) $ do - let file = dir ++ "/.ghci" - ok <- io (checkPerms file) - when ok $ do - either_hdl <- io (IO.try (openFile file ReadMode)) - case either_hdl of - Left _e -> return () - Right hdl -> runCommands (fileLoop hdl False False) + cwd <- io (getCurrentDirectory) + when (dir /= cwd) $ do + let file = dir ++ "/.ghci" + ok <- io (checkPerms file) + when ok $ do + either_hdl <- io (IO.try (openFile file ReadMode)) + case either_hdl of + Left _e -> return () + Right hdl -> runCommands (fileLoop hdl False False) -- Perform a :load for files given on the GHCi command line -- When in -e mode, if the load fails then we want to stop -- immediately rather than going on to evaluate the expression. when (not (null paths)) $ do - ok <- ghciHandle (\e -> do showException e; return Failed) $ - loadModule paths + ok <- ghciHandle (\e -> do showException e; return Failed) $ + loadModule paths when (isJust maybe_expr && failed ok) $ - io (exitWith (ExitFailure 1)) + io (exitWith (ExitFailure 1)) -- if verbosity is greater than 0, or we are connected to a -- terminal, display the prompt in the interactive loop.