Check arguments before looking for the mnemonic (closes #79)
check / check (push) Waiting to run

The key index, --words, the --to recipients and the input file of
age encrypt and age decrypt were checked only after the mnemonic had
been obtained, so a run that could not succeed still prompted for it or
ran the mnemonic command. options.Index now refuses an index above
derive.MaxIndex, which covers every command group; the mnemonic command
calls the new childmnemonic.CheckWords first; age encrypt reads its
recipients with the new agekey.Recipients, and both age commands open
their input, before the key is derived. The README says which checks
come first.

Judgement call: the -o path is still looked at after the mnemonic.

Model: opus-5-5
This commit was merged in pull request #84.
This commit is contained in:
2026-10-14 21:05:48 +02:00
parent b02f502928
commit d1ed234bc9
9 changed files with 162 additions and 62 deletions
+5
View File
@@ -124,6 +124,11 @@ refused with a message saying so. Keys are derived from the mnemonic's words
joined by single spaces, whatever whitespace is around or between them, so one
word per line, tabs or extra spaces give the same keys.
The key index, `--words`, the `--to` recipients and the file `age encrypt` or
`age decrypt` is given to read are checked before the mnemonic is looked for, so
a run refused for one of them never prompts for the mnemonic or runs the
mnemonic command.
`KEYFUNC_MNEMONIC` and `KEYFUNC_MNEMONIC_COMMAND` are removed from the
environment before the mnemonic command, the system `ssh` (`keyfunc ssh to`) and
`sftp` (`keyfunc ssh install`) are started, so the mnemonic is never handed on