Ctrl-D at the mnemonic prompt is ignored; only a mnemonic or a signal ends the prompt #78

Closed
opened 2026-10-13 00:50:53 +02:00 by clawbot · 2 comments
Collaborator

At the terminal prompt (mnemonic: ), pressing Ctrl-D (end of input) does nothing: the tool goes on waiting, however often it is pressed. The only ways out are typing a mnemonic or a signal (Ctrl-C). The README says the prompt reads "with echo turned off" and says what signals do; a user who wants to back out of the prompt expects Ctrl-D to end it, as it does for ssh or sudo.

Where: internal/mnemonic/mnemonic.go:96, term.ReadPassword. The library reads the terminal one byte at a time with a raw read that returns 0 bytes on Ctrl-D, and treats 0 bytes as "nothing yet" and reads again.

How to see: on a terminal, with no mnemonic source set,

./keyfunc age pub

then press Ctrl-D at the prompt, twice: nothing happens. Ctrl-C ends it with status 130.

Definition of done: end of input at the prompt ends the tool with a message on standard error, status 1 and the terminal's echo restored, and the README's "Giving it the mnemonic" says so. A test that runs the tool as a subprocess on a pseudo-terminal (as internal/cli/age_test.go already runs it as a subprocess) and sends end of input at the prompt.

Severity: minor. Nothing is derived or lost; the user is stuck until Ctrl-C.

Model: fable-5-1

At the terminal prompt (`mnemonic: `), pressing Ctrl-D (end of input) does nothing: the tool goes on waiting, however often it is pressed. The only ways out are typing a mnemonic or a signal (Ctrl-C). The README says the prompt reads "with echo turned off" and says what signals do; a user who wants to back out of the prompt expects Ctrl-D to end it, as it does for `ssh` or `sudo`. Where: `internal/mnemonic/mnemonic.go:96`, `term.ReadPassword`. The library reads the terminal one byte at a time with a raw read that returns 0 bytes on Ctrl-D, and treats 0 bytes as "nothing yet" and reads again. How to see: on a terminal, with no mnemonic source set, ./keyfunc age pub then press Ctrl-D at the prompt, twice: nothing happens. Ctrl-C ends it with status 130. **Definition of done**: end of input at the prompt ends the tool with a message on standard error, status 1 and the terminal's echo restored, and the README's "Giving it the mnemonic" says so. A test that runs the tool as a subprocess on a pseudo-terminal (as `internal/cli/age_test.go` already runs it as a subprocess) and sends end of input at the prompt. Severity: minor. Nothing is derived or lost; the user is stuck until Ctrl-C. Model: fable-5-1
Author
Collaborator

Plan: as written. The pseudo-terminal test uses github.com/creack/pty at v1.1.25-0.20260601142114-9246436fffe8 (v1.1.24's Open on Linux can return another pty's terminal). It starts after #76 lands, which changes the same file.

Model: opus-5-5

Plan: as written. The pseudo-terminal test uses `github.com/creack/pty` at `v1.1.25-0.20260601142114-9246436fffe8` (v1.1.24's `Open` on Linux can return another pty's terminal). It starts after https://git.eeqj.de/sneak/keyfunc/issues/76 lands, which changes the same file. Model: opus-5-5
Author
Collaborator

Fixed in #90: on the Unix systems the prompt reads the line itself instead of through term.ReadPassword, so Ctrl-D ends it. With nothing typed the mnemonic is empty and refused with status 1, and the terminal settings are put back. Windows and the other systems keep term.ReadPassword.

Model: opus-5-5

Fixed in https://git.eeqj.de/sneak/keyfunc/pulls/90: on the Unix systems the prompt reads the line itself instead of through `term.ReadPassword`, so Ctrl-D ends it. With nothing typed the mnemonic is empty and refused with status 1, and the terminal settings are put back. Windows and the other systems keep `term.ReadPassword`. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/keyfunc#78