From: Junio C Hamano Date: Thu, 19 May 2011 17:27:39 GMT Subject: Re: [PATCH] compat: add a getpass() compatibility function Message-ID: <7v62p68ut0.fsf@alter.siamese.dyndns.org> In-Reply-To: Rafael Gieschke writes: >> Windows doesn't have /dev/tty, but the logic in this version handles >> that by using stdin/stderr instead. The signal-stuff has a comment >> that indicates it might not even be correct. tcgetattr/tcsetattr isn't >> supported on Windows, but it's not needed if we use getch (as the >> version in compat/mingw.c does). POSIX/curses getch respects the >> echo-setting, while Windows getch never echo. Probably a properly abstracted common version would look like a function that calls four platform-dependent helper funcions in this order: 0. prompt 1. start "noecho" mode 2. get whole line 3. exit "noecho" mode where Windows may use stderr for 0, have noop() implementation for 1 and 3, use _getch() that does not echo for 2, while POSIX may write to /dev/tty for 0, use tc[gs]etattr() with perhaps some signal settings sprinkled in for 1 and 3. So I don't see a need for Windows to emulate tc[g]setattr nor curses in order to get a generic getpass() abstraction between two platforms.