[plt-scheme] read-line no echo

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Feb 13 13:00:25 EST 2005

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!



Posted on the users mailing list.