Browse thread
[Caml-list] How to read a password without displaying it?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-02-07 (16:31) |
From: | David Brown <caml-list@d...> |
Subject: | Re: [Caml-list] How to read a password without displaying it? |
On Sat, Feb 07, 2004 at 04:12:01PM +0100, David MENTRE wrote: > open Unix > [...] > let read_password () = > let term_init = tcgetattr stdin in > let term_no_echo = { term_init with c_echo = false; } in > tcsetattr stdin TCSANOW term_no_echo; > let password = read_line () in > tcsetattr stdin TCSAFLUSH term_init; > password The only suggestion would be to put the read_line in a try clause, and restore the terminal settings if an exception is raised. Otherwise, pressing ^C leaves the terminal with echo off. Dave ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners