diff options
author | 2014-10-31 15:46:44 -0400 | |
---|---|---|
committer | 2014-10-31 15:46:44 -0400 | |
commit | 71d1db264c8bc9691c88917d2d89c77ac36df609 (patch) | |
tree | a11f6d6b9b4af247db1c06c7e52d1678fdec5295 /Utility | |
parent | 87fe9d25b9bce6c113c1bb7293a982e12ba152f0 (diff) |
getUserEntryForID does not work on windows
Throw an error instead, mentioning the relevant env vars.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/UserInfo.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Utility/UserInfo.hs b/Utility/UserInfo.hs index 617c3e945..b3e191bbf 100644 --- a/Utility/UserInfo.hs +++ b/Utility/UserInfo.hs @@ -48,8 +48,11 @@ myUserGecos = myVal [] userGecos #endif myVal :: [String] -> (UserEntry -> String) -> IO String -myVal envvars extract = maybe (extract <$> getpwent) return =<< check envvars +myVal envvars extract = go envvars where - check [] = return Nothing - check (v:vs) = maybe (check vs) (return . Just) =<< getEnv v - getpwent = getUserEntryForID =<< getEffectiveUserID +#ifndef mingw32_HOST_OS + go [] = extract <$> (getUserEntryForID =<< getEffectiveUserID) +#else + go [] = error $ "environment not set: " ++ show envvars +#endif + go (v:vs) = maybe (go vs) return =<< getEnv v |