aboutsummaryrefslogtreecommitdiff
path: root/Utility/Process.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-11-19 00:55:33 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-11-19 00:59:45 -0400
commitb3289d508dafcc59d947c1853d79e1cf68d5e807 (patch)
treebfdf8503a20af7a7c002b7ca9c8f3b8a74420d4f /Utility/Process.hs
parent497835f03a068b70b9c94970138dfd50485f4d40 (diff)
more general readProcess' merged from propellor
Diffstat (limited to 'Utility/Process.hs')
-rw-r--r--Utility/Process.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/Utility/Process.hs b/Utility/Process.hs
index e25618eba..4550d94f9 100644
--- a/Utility/Process.hs
+++ b/Utility/Process.hs
@@ -13,6 +13,7 @@ module Utility.Process (
CreateProcess(..),
StdHandle(..),
readProcess,
+ readProcess',
readProcessEnv,
writeReadProcessEnv,
forceSuccessProcess,
@@ -66,17 +67,19 @@ readProcess :: FilePath -> [String] -> IO String
readProcess cmd args = readProcessEnv cmd args Nothing
readProcessEnv :: FilePath -> [String] -> Maybe [(String, String)] -> IO String
-readProcessEnv cmd args environ =
- withHandle StdoutHandle createProcessSuccess p $ \h -> do
- output <- hGetContentsStrict h
- hClose h
- return output
+readProcessEnv cmd args environ = readProcess' p
where
p = (proc cmd args)
{ std_out = CreatePipe
, env = environ
}
+readProcess' :: CreateProcess -> IO String
+readProcess' p = withHandle StdoutHandle createProcessSuccess p $ \h -> do
+ output <- hGetContentsStrict h
+ hClose h
+ return output
+
{- Runs an action to write to a process on its stdin,
- returns its output, and also allows specifying the environment.
-}