scheme shell
about
download
support
resources
docu
links
 
scsh.net

Read Password

A procedure that reads text without echoing it -- useful for password prompts.

-Eric

See also GettingUserInputSansEcho.


  ;; ,open let-opt

;; read string without echoing it ;; optionals arguments: ;; prompt - a string to be display before reading (default none) ;; port - the port to read from (default current-input-port) (define (read-password . args) (let-optionals args ((prompt #f) (port (current-input-port))) (let* ((tty-before (tty-info port)) (tty-sans-echo (copy-tty-info tty-before))) (if prompt (begin (display prompt) (force-output (current-output-port)))) (set-tty-info:local-flags tty-sans-echo (bitwise-and (tty-info:local-flags tty-sans-echo) (bitwise-not ttyl/echo))) (set-tty-info/now port tty-sans-echo) (let ((password (read-line port))) (set-tty-info/now port tty-before) (flush-tty/both port) password))))


ReadPassword - raw wiki source | code snippets archive