[plt-scheme] read-line no echo
On Feb 13, john m wrote:
> I am trying to implement a password prompt where characters are not
> echoed. I have searched around but not found a solution. I have
> managed to kludge a solution by using (system ...) and accessing the
> bash command 'read -s'. Is there a scheme solution or does this need
> an extension written in C? I only need to support OS X and Linux.
You can use stty:
(require 'process)
(define (get-passwd)
(dynamic-wind
(lambda ()
(printf "password: ") (system* "/bin/stty" "-echo" "echonl"))
read-line
(lambda () (system* "/bin/stty" "echo"))))
(get-passwd)
but I don't think there's an obvious way to avoid a system command
(unless you're willing to write C). Otherwise, mred would be more
convenient and portable.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!