From: David Brown <caml-list@davidb.org>
To: David MENTRE <dmentre@linux-france.org>
Cc: Alain.Frisch@ens.fr, caml-list@inria.fr
Subject: Re: [Caml-list] How to read a password without displaying it?
Date: Sat, 7 Feb 2004 08:31:18 -0800 [thread overview]
Message-ID: <20040207163118.GA20250@davidb.org> (raw)
In-Reply-To: <874qu2sz3y.fsf@linux-france.org>
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
prev parent reply other threads:[~2004-02-07 16:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-07 12:53 David MENTRE
2004-02-07 13:17 ` Basile STARYNKEVITCH
2004-02-07 13:42 ` Maxence Guesdon
2004-02-07 14:45 ` David MENTRE
2004-02-07 14:54 ` David MENTRE
2004-02-07 14:59 ` Remi Vanicat
2004-02-07 14:50 ` Alain.Frisch
2004-02-07 15:12 ` David MENTRE
2004-02-07 16:31 ` David Brown [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040207163118.GA20250@davidb.org \
--to=caml-list@davidb.org \
--cc=Alain.Frisch@ens.fr \
--cc=caml-list@inria.fr \
--cc=dmentre@linux-france.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox