[commit: ghc] master: :cd affects the iserv process too (dfac365)
git at git.haskell.org
git at git.haskell.org
Sun Apr 2 16:02:30 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/dfac365f69a9380e3c3640b3bfaf9b9157f8d3b9/ghc
>---------------------------------------------------------------
commit dfac365f69a9380e3c3640b3bfaf9b9157f8d3b9
Author: Simon Marlow <marlowsd at gmail.com>
Date: Sun Apr 2 10:43:32 2017 -0400
: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
>---------------------------------------------------------------
dfac365f69a9380e3c3640b3bfaf9b9157f8d3b9
ghc/GHCi/UI.hs | 5 +++++
testsuite/tests/ghci/scripts/GhciCurDir.script | 7 +++++++
testsuite/tests/ghci/scripts/all.T | 1 +
3 files changed, 13 insertions(+)
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 71be20c..deee24a 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 0000000..785a773
--- /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 00d8d81..cde72e4 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'])
More information about the ghc-commits
mailing list