Files
keyfunc/internal/mnemonic/prompt_notunix.go
T
clawbot d3ca2e0d57
check / check (push) Waiting to run
End the mnemonic prompt at end of input (closes #78)
term.ReadPassword reads the terminal with a raw read that returns 0
bytes at the end of input and takes that as nothing yet, so Ctrl-D at
the prompt did nothing. On the Unix systems the prompt now sets the
terminal as ReadPassword does and reads the line from standard input,
which reports the end of input; elsewhere, such as Windows, it still
uses ReadPassword. Ctrl-D with nothing typed gives an empty mnemonic,
refused with status 1, and the terminal settings are put back.

A test runs the tool on a pseudo-terminal (github.com/creack/pty, at a
commit past v1.1.24, whose Open on Linux can return another pty's
terminal) and types Ctrl-D at the prompt.

Model: opus-5-5
2026-10-14 21:09:14 +00:00

19 lines
479 B
Go

//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !zos
package mnemonic
import (
"os"
"golang.org/x/term"
)
// readWithoutEcho reads one line from the terminal on standard input
// with echo turned off, through term.ReadPassword, on the systems
// prompt_unix.go is not built for, such as Windows.
func readWithoutEcho() (string, error) {
typed, err := term.ReadPassword(int(os.Stdin.Fd()))
return string(typed), err
}