From e1886d81c5df2d77f5275a2a2bc16a0a4a22ba41 Mon Sep 17 00:00:00 2001 From: Luigy Leon Date: Tue, 1 Mar 2016 17:08:14 -0500 Subject: [PATCH] 'stack ghci' is now spawned fixes #1306 --- src/Stack/Exec.hs | 23 +++++++++++++++-------- src/Stack/Ghci.hs | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Stack/Exec.hs b/src/Stack/Exec.hs index 365fe57740..691221a994 100644 --- a/src/Stack/Exec.hs +++ b/src/Stack/Exec.hs @@ -14,16 +14,16 @@ import Control.Monad.Catch hiding (try) import Control.Monad.Trans.Control (MonadBaseControl) import Stack.Types import System.Process.Log -import System.Process.Read (EnvOverride) -#ifdef WINDOWS import Control.Exception.Lifted import Data.Streaming.Process (ProcessExitedUnsuccessfully(..)) import System.Exit import System.Process.Run (callProcess, Cmd(..)) +#ifdef WINDOWS +import System.Process.Read (EnvOverride) #else -import System.Process.Read (envHelper, preProcess) import System.Posix.Process (executeFile) +import System.Process.Read (EnvOverride, envHelper, preProcess) #endif -- | Default @EnvSettings@ which includes locals and GHC_PACKAGE_PATH @@ -47,14 +47,21 @@ plainEnvSettings = EnvSettings -- | Execute a process within the Stack configured environment. exec :: (MonadIO m, MonadLogger m, MonadThrow m, MonadBaseControl IO m) => EnvOverride -> String -> [String] -> m b +#ifdef WINDOWS +exec = execSpawn +#else exec menv cmd0 args = do $logProcessRun cmd0 args -#ifdef WINDOWS + cmd <- preProcess Nothing menv cmd0 + liftIO $ executeFile cmd True args (envHelper menv) +#endif + +-- | Execute a spawned process within the Stack configured environment. +execSpawn :: (MonadIO m, MonadLogger m, MonadThrow m, MonadBaseControl IO m) + => EnvOverride -> String -> [String] -> m b +execSpawn menv cmd0 args = do + $logProcessRun cmd0 args e <- try (callProcess (Cmd Nothing cmd0 menv args)) liftIO $ case e of Left (ProcessExitedUnsuccessfully _ ec) -> exitWith ec Right () -> exitSuccess -#else - cmd <- preProcess Nothing menv cmd0 - liftIO $ executeFile cmd True args (envHelper menv) -#endif diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 78476d3738..7cf6c9b79d 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -145,7 +145,7 @@ ghci opts@GhciOpts{..} = do T.intercalate ", " (map (packageNameText . ghciPkgName) pkgs)) let execGhci extras = do menv <- liftIO $ configEnvOverride config defaultEnvSettings - exec menv + execSpawn menv (fromMaybe (compilerExeName wc) ghciGhcCommand) ("--interactive" : -- This initial "-i" resets the include directories to not