Re: [PATCH] compat: add a getpass() compatibility function
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 19, 2011, 16:30 UTC
- Message-ID
- <7vmxii8xgv.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <BANLkTinPHeSfZXRb7pqt7-XWkR5fH=wAjg@mail.gmail.com>
Erik Faye-Lund <kusmabite@gmail.com> writes:
> Do we really need two implementations? Wouldn't it be better to factor > out the mingw-version to a separate source file, and then improve it?
Thanks for reminding.
Show 6 quoted lines
> 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.
I forgot to check how generic/reusable mingw version would look. As you said, it does feel a lot more attractive approach if it is trivial to add the "noecho" bit to it, tweak the tty-ness and deal with signals.
I however suspect the result would end up on the borderline to be called "trivial", rough guestimate being 3-4 times as large as the 14-line mingw version. But it certainly feels that it is worth a try.