git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] compat: add a getpass() compatibility function

From
Junio C Hamano <gitster@pobox.com>
Date
May 19, 2011, 17:27 UTC
Message-ID
<7v62p68ut0.fsf@alter.siamese.dyndns.org>
In-Reply-To
<EC81F772-7149-40A0-891A-973C886AB052@gieschke.de>
Rafael Gieschke <rafael@gieschke.de> writes:
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.

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.

Previous: Rafael GieschkeNext: Erik Faye-Lund
Message 5 of 19 in “compat: add a getpass() compatibility function”
  1. compat: add a getpass() compatibility functionRafael Gieschke, May 19, 2011
  2. Erik Faye-LundMay 19, 2011
  3. Junio C HamanoMay 19, 2011
  4. Rafael GieschkeMay 19, 2011
  5. Junio C HamanoMay 19, 2011
  6. Erik Faye-LundMay 19, 2011
  7. Rafael GieschkeMay 19, 2011
  8. Erik Faye-LundMay 19, 2011
  9. Rafael GieschkeMay 19, 2011
  10. Erik Faye-LundMay 19, 2011
  11. Erik Faye-LundMay 19, 2011
  12. Rafael GieschkeMay 20, 2011
  13. Erik Faye-LundMay 20, 2011
  14. Junio C HamanoMay 20, 2011
  15. Erik Faye-LundMay 20, 2011
  16. Erik Faye-LundMay 19, 2011
  17. Jonathan NiederMay 19, 2011
  18. Erik Faye-LundMay 19, 2011
  19. Junio C HamanoMay 19, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.