Handle :cd in external interpreter in a more robust way
authorZejun Wu <watashi@fb.com>
Mon, 17 Dec 2018 06:16:00 +0000 (01:16 -0500)
committerBen Gamari <ben@smart-cactus.org>
Mon, 17 Dec 2018 06:16:01 +0000 (01:16 -0500)
commitf99d898ba384b7d3ace7aae71b0125ba645e09cb
treee4330e3ab6c8d73063e25688bd73a45a339696cd
parentc42eb2e67ae7f1e77c7bf365b7a41f808bc606cc
Handle :cd in external interpreter in a more robust way

We used to enqueue another command to change directory in the external
interpreter subprocess, this is not as robust as:

* it can fail with -fno-implict-import-qualified;
* it doesn't work when we `setGHCiMonad` to something other than `IO`.

Neither of them works if `directory` package is hidden though.

Test Plan:
```
$ inplace/bin/ghc-stage2 --interactive # -fexternal-interpreter
GHCi, version 8.7.20181213: http://www.haskell.org/ghc/  :? for help
Prelude> :cd ..
Prelude> System.Directory.getCurrentDirectory
"/data/users/watashi"
Prelude> :!pwd
/data/users/watashi
Prelude>
Leaving GHCi.
```

  ./validate

Reviewers: simonmar, bgamari, RyanGlScott

Reviewed By: simonmar

Subscribers: rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5453
ghc/GHCi/UI.hs
ghc/GHCi/UI/Monad.hs