Repository navigation
Reject a mistyped subcommand instead of running its parent - #17016
Liukskywalkerr wants to merge 1 commit into
Conversation
[Medium impact] The change reaches shared command routing for a bounded set of command groups. Fix the leading-flag bypass before merging; a mistyped child can still start a full system update. Findings
SummaryThe PR rejects mistyped children of commands whose declared arguments are only flags.
Reviews (1) · Last reviewed commit: "Reject a mistyped subcommand instead of ..." · Reviewed by Greptile |
| if (( ${#remaining[@]} > 0 )) && [[ ${remaining[0]} != -* ]]; then | ||
| load_command_by_binary "$DIRECT_RESOLVED_BINARY" | ||
| key="${BINARY_TO_KEY[$DIRECT_RESOLVED_BINARY]}" | ||
| if [[ -n $key ]] && reject_mistyped_child "$key" "${remaining[0]}"; then |
There was a problem hiding this comment.
Leading flags bypass typo checks
For omarchy update -y firmwre, remaining[0] is -y, so this check is skipped. The alias path also checks only the first leftover argument. Both routes run omarchy-update -y firmwre, which skips the update confirmation and starts the full update after sudo authorization.
Check the remaining arguments before -- for unexpected words in both routes, and add this case to the regression test.
|
Thanks @Liukskywalkerr. This fixes a real problem: on What was checked. I read this diff and #16944's against the dispatcher in Why #16944. It is older, and it handles a case this branch misses, the one Greptile flagged above. Here What carries over. Your test that a flags-only parent still takes its flag ( Next. Waiting on the maintainer, who chooses between the two. |
|
Closing in favor of #16944, which also handles the leading-flag case ( |
Fixes #16770.
A mistyped subcommand fell back to its parent with the typo as an argument, so
omarchy update firmwre(oromarchy up spotifast) showed the normal update prompt and ran a full system update.When the resolved command takes only flags (per its
omarchy:args) and has child commands of its own, a leftover word that isn't a flag is now treated as a mistyped child:It exits 127 like other unknown commands. The check runs in both the direct route and the alias/full-table route, so it covers every flags-only group (not just
update), and flags (omarchy update -y) still pass through. Commands that take positional arguments, or have noargsmetadata, are untouched.test/cligets one case that fails onquattroand passes with the change (direct and alias route, plus the flag still forwarding). Fulltest/clipasses.