From 71dc0d155a4ef408a51db849b426e8493dacac5c Mon Sep 17 00:00:00 2001 From: Yvan Sraka Date: Fri, 3 Nov 2023 13:23:25 +0100 Subject: [PATCH] Use `createProcess` instead of `callExternal` --- Cabal/src/Distribution/Simple/Command.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Command.hs b/Cabal/src/Distribution/Simple/Command.hs index ae191ccc30a..33c2b1960f5 100644 --- a/Cabal/src/Distribution/Simple/Command.hs +++ b/Cabal/src/Distribution/Simple/Command.hs @@ -93,8 +93,8 @@ import qualified Distribution.GetOpt as GetOpt import Distribution.ReadE import Distribution.Simple.Utils import System.Directory (findExecutable) -import System.Process (callProcess) -import System.Environment (getExecutablePath, setEnv) +import System.Process (createProcess, CreateProcess (env), proc) +import System.Environment (getExecutablePath) data CommandUI flags = CommandUI { commandName :: String @@ -652,10 +652,7 @@ commandsRun globalCommand commands args = _ -> do mCommand <- findExecutable $ "cabal-" <> name case mCommand of - Just exec -> do - execPath <- getExecutablePath - void $ setEnv "CABAL" execPath - callExternal flags exec cmdArgs + Just exec -> callExternal flags exec cmdArgs Nothing -> pure $ CommandReadyToGo (flags, badCommand name) [] -> pure $ CommandReadyToGo (flags, noCommand) where @@ -667,7 +664,8 @@ commandsRun globalCommand commands args = callExternal :: a -> String -> [String] -> IO (CommandParse (a, CommandParse action)) callExternal flags exec cmdArgs = do - result <- try $ callProcess exec cmdArgs + execPath <- getExecutablePath + result <- try $ createProcess (proc exec cmdArgs) { env = Just [("CABAL", execPath)] } case result of Left ex -> pure $ CommandErrors ["Error executing external command: " ++ show (ex :: SomeException)] Right _ -> pure $ CommandReadyToGo (flags, CommandDelegate)