summaryrefslogtreecommitdiff
path: root/Utility/UserInfo.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <id@joeyh.name>2013-05-12 15:38:15 -0500
committerGravatar Joey Hess <id@joeyh.name>2013-05-12 15:38:15 -0500
commit4bdcf788b375f58bc13b5e4d1d35dad90fb967c0 (patch)
treea999de7f61fa14be345ada9f771393606cde9dfc /Utility/UserInfo.hs
parenta3c1d8927e4e754fed80787a001899998e758915 (diff)
check addition env vars so it works on Windows outside of Cygwin
Diffstat (limited to 'Utility/UserInfo.hs')
-rwxr-xr-x[-rw-r--r--]Utility/UserInfo.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/Utility/UserInfo.hs b/Utility/UserInfo.hs
index bc94ea8a1..3a71c6baf 100644..100755
--- a/Utility/UserInfo.hs
+++ b/Utility/UserInfo.hs
@@ -22,11 +22,23 @@ import Utility.Env
-
- getpwent will fail on LDAP or NIS, so use HOME if set. -}
myHomeDir :: IO FilePath
-myHomeDir = myVal ["HOME"] homeDirectory
+myHomeDir = myVal env homeDirectory
+ where
+#ifndef __WINDOWS__
+ env = ["HOME"]
+#else
+ env = ["USERPROFILE", "HOME"] -- HOME is used in Cygwin
+#endif
{- Current user's user name. -}
myUserName :: IO String
-myUserName = myVal ["USER", "LOGNAME"] userName
+myUserName = myVal env userName
+ where
+#ifndef __WINDOWS__
+ env = ["USER", "LOGNAME"]
+#else
+ env = ["USERNAME", "USER", "LOGNAME"]
+#endif
myUserGecos :: IO String
#ifdef __ANDROID__