mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 03:44:14 +00:00
flush stdout when prompting for password (#25348)
Saw this misbehave on Linux. It was fine in Windows when I checked, but
I figured it can't hurt.
(cherry picked from commit 8747160a9a)
This commit is contained in:
committed by
narimiran
parent
90b7517656
commit
a69ab81fa9
@@ -909,6 +909,7 @@ when defined(windows):
|
||||
## `true` otherwise.
|
||||
password.setLen(0)
|
||||
stdout.write(prompt)
|
||||
stdout.flushFile()
|
||||
let hi = createFileA("CONIN$",
|
||||
GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, 0, 0)
|
||||
var mode = DWORD 0
|
||||
@@ -936,6 +937,7 @@ else:
|
||||
cur.c_lflag = cur.c_lflag and not Cflag(ECHO)
|
||||
discard fd.tcSetAttr(TCSADRAIN, cur.addr)
|
||||
stdout.write prompt
|
||||
stdout.flushFile()
|
||||
result = stdin.readLine(password)
|
||||
stdout.write "\n"
|
||||
discard fd.tcSetAttr(TCSADRAIN, old.addr)
|
||||
|
||||
Reference in New Issue
Block a user