fixes for Unix build
This commit is contained in:
parent
924ed999c5
commit
d6bf05a66d
1 changed files with 12 additions and 5 deletions
|
@ -13,7 +13,7 @@ module Utility.Env where
|
||||||
import qualified System.Environment as E
|
import qualified System.Environment as E
|
||||||
import Utility.Exception
|
import Utility.Exception
|
||||||
#else
|
#else
|
||||||
import qualified System.Posix.Environment as E
|
import qualified System.Posix.Env as E
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{- Posix getEnv is faster than the one in System.Environment,
|
{- Posix getEnv is faster than the one in System.Environment,
|
||||||
|
@ -25,15 +25,22 @@ getEnv = E.getEnv
|
||||||
getEnv = catchMaybeIO . E.getEnv
|
getEnv = catchMaybeIO . E.getEnv
|
||||||
#endif
|
#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.
|
{- Returns True if it could successfully set the environment variable.
|
||||||
-
|
-
|
||||||
- There is, apparently, no way to do this in Windows. Instead,
|
- There is, apparently, no way to do this in Windows. Instead,
|
||||||
- environment varuables must be provided when running a new process. -}
|
- environment varuables must be provided when running a new process. -}
|
||||||
setEnv :: String -> String -> IO Bool
|
setEnv :: String -> String -> Bool -> IO Bool
|
||||||
#ifndef __WINDOWS__
|
#ifndef __WINDOWS__
|
||||||
setEnv var val = do
|
setEnv var val overwrite = do
|
||||||
E.setEnv var val
|
E.setEnv var val overwrite
|
||||||
return True
|
return True
|
||||||
#else
|
#else
|
||||||
setEnv _ _ = return False
|
setEnv _ _ _ = return False
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue