assistant: Detect when system is not configured with a user name, and set environment to prevent git from failing.

This commit is contained in:
Joey Hess 2013-01-06 13:34:08 -04:00
parent 24df1f6ee0
commit 13d2fffb2d
4 changed files with 35 additions and 1 deletions

View file

@ -7,7 +7,8 @@
module Utility.UserInfo (
myHomeDir,
myUserName
myUserName,
myUserGecos,
) where
import Control.Applicative
@ -24,6 +25,9 @@ myHomeDir = myVal ["HOME"] homeDirectory
myUserName :: IO String
myUserName = myVal ["USER", "LOGNAME"] userName
myUserGecos :: IO String
myUserGecos = myVal [] userGecos
myVal :: [String] -> (UserEntry -> String) -> IO String
myVal envvars extract = maybe (extract <$> getpwent) return =<< check envvars
where