<div dir="ltr">Thank you very much, works like a charm!<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 12 Feb 2023 at 16:16, Raymond Wiker <<a href="mailto:rwiker@gmail.com">rwiker@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><br><div><blockquote type="cite"><div>On 12 Feb 2023, at 11:47, Alessio Stalla <<a href="mailto:alessiostalla@gmail.com" target="_blank">alessiostalla@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div>Greetings everyone,</div><div><br></div><div>is there a well-known way to do the thing in the subject, i.e. ask the user for a password in a console application, reading from the keyboard without echoing anything to the terminal? Using a library is fine, SBCL only is fine, limited to some OS is not so fine but better than nothing. Any idea?<br></div></div>
</div></blockquote></div><br><div><br></div><div>Here’s something that I’ve used for Lispworks and SBCL:</div><div><br></div><div><div><br></div><div><font face="Monaco"><span style="font-style:normal">#+sbcl</span></font></div><div><font face="Monaco"><span style="font-style:normal">(require :sb-posix)</span></font></div><div><font face="Monaco"><span style="font-style:normal"><br></span></font></div><div><font face="Monaco"><span style="font-style:normal">#+sbcl</span></font></div><div><font face="Monaco"><span style="font-style:normal">(defun echo-off ()</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (let ((tm (sb-posix:tcgetattr sb-sys:*tty*)))</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (setf (sb-posix:termios-lflag tm)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (logandc2 (sb-posix:termios-lflag tm) sb-posix:echo))</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (sb-posix:tcsetattr sb-sys:*tty* sb-posix:tcsanow tm)))</span></font></div><div><font face="Monaco"><span style="font-style:normal"><br></span></font></div><div><font face="Monaco"><span style="font-style:normal">#+sbcl</span></font></div><div><font face="Monaco"><span style="font-style:normal">(defun echo-on ()</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (let ((tm (sb-posix:tcgetattr sb-sys:*tty*)))</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (setf (sb-posix:termios-lflag tm)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (logior (sb-posix:termios-lflag tm) sb-posix:echo))</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (sb-posix:tcsetattr sb-sys:*tty* sb-posix:tcsanow tm)))</span></font></div><div><font face="Monaco"><span style="font-style:normal"><br></span></font></div><div><font face="Monaco"><span style="font-style:normal">#+sbcl</span></font></div><div><font face="Monaco"><span style="font-style:normal">(defun prompt-for-value (prompt)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (format t "~&~a " prompt)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (force-output)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (read-line))</span></font></div><div><font face="Monaco"><span style="font-style:normal"><br></span></font></div><div><font face="Monaco"><span style="font-style:normal">#+sbcl</span></font></div><div><font face="Monaco"><span style="font-style:normal">(defun prompt-for-value/no-echo (prompt)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (format t "~&~a " prompt)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (force-output)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (echo-off)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (unwind-protect</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (read-line)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (echo-on)))</span></font></div><div><font face="Monaco"><span style="font-style:normal"><br></span></font></div><div><font face="Monaco"><span style="font-style:normal">#+capi</span></font></div><div><font face="Monaco"><span style="font-style:normal">(defun prompt-for-value (prompt)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (capi:prompt-for-string prompt))</span></font></div><div><font face="Monaco"><span style="font-style:normal"><br></span></font></div><div><font face="Monaco"><span style="font-style:normal">#+capi</span></font></div><div><font face="Monaco"><span style="font-style:normal">(defun prompt-for-value/no-echo (prompt)</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (capi:prompt-for-string prompt :pane-class 'capi:password-pane))</span></font></div><div><font face="Monaco"><span style="font-style:normal"><br></span></font></div><div><font face="Monaco"><span style="font-style:normal">(defun get-passphrase-from-user ()</span></font></div><div><font face="Monaco"><span style="font-style:normal"> (prompt-for-value/no-echo "Passphrase?"))</span></font></div></div><div><br></div></div></blockquote></div>