aboutsummaryrefslogtreecommitdiff
path: root/Utility/Env.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-11 17:27:21 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-11 17:27:21 -0400
commitdb56fab07ddd6910b1dc08f4fa242c267c469eb5 (patch)
tree55906a818d4d4bd494bbc475752bd68bc3db2ad6 /Utility/Env.hs
parent16c3e2bcd4e6aa67dd8bad95069d8d1f57a96b3a (diff)
fixes for Unix build
Diffstat (limited to 'Utility/Env.hs')
-rwxr-xr-xUtility/Env.hs17
1 files changed, 12 insertions, 5 deletions
diff --git a/Utility/Env.hs b/Utility/Env.hs
index 713360154..c6f051052 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