diff options
| author | Joey Hess <joey@kitenet.net> | 2014-11-19 01:02:13 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-11-19 01:02:13 -0400 |
| commit | 05086b3abe8d633ae788354a3cc9bb0bd72f6159 (patch) | |
| tree | f43c2d42dfe7f43cd6fe1a8ed09fdca2145a1cf0 /src/Utility | |
| parent | 9a779939c4252dc99b888d9fa6cd6d8f3b169610 (diff) | |
propellor spin
Diffstat (limited to 'src/Utility')
| -rw-r--r-- | src/Utility/Process.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Utility/Process.hs b/src/Utility/Process.hs index e25618eb..4550d94f 100644 --- a/src/Utility/Process.hs +++ b/src/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. -} |
