End the mnemonic prompt at end of input (closes #78)
check / check (push) Waiting to run

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. The prompt now sets the terminal as
ReadPassword does and reads the line from standard input, which
reports the end of input. 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
This commit is contained in:
2026-10-14 20:26:26 +00:00
parent 5582c02edf
commit 2d4e0bc335
7 changed files with 142 additions and 6 deletions
+4 -1
View File
@@ -116,7 +116,10 @@ order; the first one found wins:
2. Environment variable `KEYFUNC_MNEMONIC_COMMAND`: the same, as a shell command
held in the environment.
3. Environment variable `KEYFUNC_MNEMONIC`: the mnemonic itself.
4. A prompt on the terminal with echo turned off.
4. A prompt on the terminal with echo turned off. The mnemonic is what is typed
up to Enter or the end of input (Ctrl-D), and echo is turned back on once it
is read. Ctrl-D with nothing typed leaves the mnemonic empty, so the tool
refuses it and exits with status 1.
If none of these is available and standard input is not a terminal, the tool
refuses and exits with status 1. A mnemonic that is empty, does not have 12, 15,