From d6bf05a66d37b3171299f6b355521b3e6756dc6f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 11 May 2013 17:27:21 -0400 Subject: [PATCH] fixes for Unix build --- Utility/Env.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Utility/Env.hs b/Utility/Env.hs index 7133601548..c6f051052f 100755 --- a/Utility/Env.hs +++ b/Utility/Env.hs @@ -13,7 +13,7 @@ module Utility.Env where import qualified System.Environment as E import Utility.Exception #else -import qualified System.Posix.Environment as E +import qualified System.Posix.Env as E #endif {- Posix getEnv is faster than the one in System.Environment, @@ -25,15 +25,22 @@ getEnv = E.getEnv getEnv = catchMaybeIO . E.getEnv #endif +getEnvDefault :: String -> String -> IO String +#ifndef __WINDOWS__ +getEnvDefault = E.getEnvDefault +#else +getEnvDefault var fallback = fromMaybe fallback <$> getEnv var +#endif + {- Returns True if it could successfully set the environment variable. - - There is, apparently, no way to do this in Windows. Instead, - environment varuables must be provided when running a new process. -} -setEnv :: String -> String -> IO Bool +setEnv :: String -> String -> Bool -> IO Bool #ifndef __WINDOWS__ -setEnv var val = do - E.setEnv var val +setEnv var val overwrite = do + E.setEnv var val overwrite return True #else -setEnv _ _ = return False +setEnv _ _ _ = return False #endif