diff options
author | Simon Marlow <marlowsd@gmail.com> | 2017-04-02 10:43:32 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-04-02 12:01:47 -0400 |
commit | dfac365f69a9380e3c3640b3bfaf9b9157f8d3b9 (patch) | |
tree | 29235e374625181b53820407de7c5572a376e9c6 | |
parent | 61ba4518a48727f8cd7b821bd41631da82d37425 (diff) | |
download | haskell-dfac365f69a9380e3c3640b3bfaf9b9157f8d3b9.tar.gz |
:cd affects the iserv process too
Test Plan: validate
Reviewers: angerman, austin, bgamari, erikd
Reviewed By: bgamari
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3395
-rw-r--r-- | ghc/GHCi/UI.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/GhciCurDir.script | 7 | ||||
-rwxr-xr-x | testsuite/tests/ghci/scripts/all.T | 1 |
3 files changed, 13 insertions, 0 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 71be20c20e..deee24ab33 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -1409,6 +1409,11 @@ changeDirectory dir = do GHC.workingDirectoryChanged dir' <- expandPath dir liftIO $ setCurrentDirectory dir' + dflags <- getDynFlags + -- With -fexternal-interpreter, we have to change the directory of the subprocess too. + -- (this gives consistent behaviour with and without -fexternal-interpreter) + when (gopt Opt_ExternalInterpreter dflags) $ + lift $ enqueueCommands ["System.Directory.setCurrentDirectory " ++ show dir'] trySuccess :: GHC.GhcMonad m => m SuccessFlag -> m SuccessFlag trySuccess act = diff --git a/testsuite/tests/ghci/scripts/GhciCurDir.script b/testsuite/tests/ghci/scripts/GhciCurDir.script new file mode 100644 index 0000000000..785a773a0a --- /dev/null +++ b/testsuite/tests/ghci/scripts/GhciCurDir.script @@ -0,0 +1,7 @@ +import System.Directory +import Control.Monad + +createDirectory "test" +createDirectory "test/test1" +:cd test +unless ("test1" `elem` getDirectoryContents ".") $ putStrLn "Uh oh." diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T index 00d8d819bc..cde72e4d2d 100755 --- a/testsuite/tests/ghci/scripts/all.T +++ b/testsuite/tests/ghci/scripts/all.T @@ -251,3 +251,4 @@ test('StaticPtr', normal, ghci_script, ['StaticPtr.script']) test('T13202', normal, ghci_script, ['T13202.script']) test('T13202a', normal, ghci_script, ['T13202a.script']) test('T13466', normal, ghci_script, ['T13466.script']) +test('GhciCurDir', normal, ghci_script, ['GhciCurDir.script']) |