I this there's no need for a binding

How about this?

import Control.Monad (when)
import System.IO

getpasswd :: Handle -> IO String
getpasswd h = do wasEnabled <- hGetEcho h
                                 when  wasEnabled (hSetEcho h False)
                                 str <- hGetLine h
                                 when wasEnabled (hSetEcho h True)
                                 return str

On Nov 9, 2007 5:20 PM, Thomas Schilling <[EMAIL PROTECTED]> wrote:
> On Fri, 2007-11-09 at 10:59 -0500, Taylor Venable wrote:
> > Hello all,
> >
> > I've written a little Haskell program to get information from a MySQL
> > database (great thanks to anybody reading this who works on HSQL, by
> > the way) but I want to keep the user's password concealed, obviously.
> > Currently I prompt for it from the terminal, but the problem is that
> > it's echoed just like all other input.  I would like to disable input
> > echo when asking for the password, but I'm not sure how.  I notice
> > there's a System.POSIX.Terminal module, but I have no idea how to use
> > it, or whether it will do what I want.  Any ideas would be greatly
> > appreciated.
> >
> > Best regards.
> >
>
> In C you usually use:  getpasswd
>   (http://docsrv.sco.com:507/en/man/html.S/getpasswd.S.html)
>
> I cannot find it System.Posix, so you might have to write your own FFI
> bindings.  Otherwise, you can play around with the terminal modes from:
>
> http://haskell.org/ghc/docs/latest/html/libraries/unix-2.2.0.0/System-Posix-Terminal.html#t%3ATerminalMode
>
> Good luck!
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to