From: simonmar Date: Mon, 21 Jul 2003 14:33:19 +0000 (+0000) Subject: [project @ 2003-07-21 14:33:19 by simonmar] X-Git-Tag: Approx_11550_changesets_converted~671 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=95f1b72e5398f6d4b694ff7a62e73243dd9a6ee9;p=ghc-hetmet.git [project @ 2003-07-21 14:33:19 by simonmar] :cd now causes all modules to be unloaded. This is the easy fix for a problem whereby changing directories will cause GHC to try to demand-load objects from the wrong place, because it is using relative pathnames. It's not obvious what the "right" thing to do is if the user changes directory with :cd and then does a :reload. Perhaps the right thing to do is to make the search path "sticky", so that it stays relative to the original current directory. This would probably require some re-engineering of GHC to only use absolute paths internally. --- diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index f74285c..5c014be 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.156 2003/07/02 19:41:43 ross Exp $ +-- $Id: InteractiveUI.hs,v 1.157 2003/07/21 14:33:19 simonmar Exp $ -- -- GHC Interactive User Interface -- @@ -542,6 +542,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)