summaryrefslogtreecommitdiffhomepage
path: root/ControlWindow.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ControlWindow.hs')
-rw-r--r--ControlWindow.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/ControlWindow.hs b/ControlWindow.hs
index bd79d0f..29c81c9 100644
--- a/ControlWindow.hs
+++ b/ControlWindow.hs
@@ -98,9 +98,20 @@ type Response = String
type PromptChan = TChan Prompt
type ResponseChan = TChan Response
+-- | Get a name for the debug-me user. When possible this will be the
+-- actual username, but failing that, anything reasonable will do,
+-- since it's only ever displayed to the person they are communicating
+-- with.
+getUserName :: IO String
+getUserName = do
+ loginname <- try getLoginName :: IO (Either SomeException String)
+ case loginname of
+ Right n -> return n
+ Left _ -> return "user"
+
collectOutput :: TMChan ControlOutput -> PromptChan -> ResponseChan -> IO ()
collectOutput ochan promptchan responsechan = do
- myusername <- fromString <$> getLoginName
+ myusername <- fromString <$> getUserName
loop myusername
where
loop myusername = do