Skip to content

Reject a mistyped subcommand instead of running its parent - #17016

Closed
Liukskywalkerr wants to merge 1 commit into
omacom:quattrofrom
Liukskywalkerr:fix/mistyped-subcommand
Closed

Liukskywalkerr wants to merge 1 commit into
omacom:quattrofrom
Liukskywalkerr:fix/mistyped-subcommand

Conversation

@Liukskywalkerr

Copy link
Copy Markdown

Fixes #16770.

A mistyped subcommand fell back to its parent with the typo as an argument, so omarchy update firmwre (or omarchy 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:

$ omarchy update firmwre
Unknown Omarchy command: omarchy update firmwre
Run 'omarchy update --help' to see its commands.

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 no args metadata, are untouched.

test/cli gets one case that fails on quattro and passes with the change (direct and alias route, plus the flag still forwarding). Full test/cli passes.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P1 Leading flags bypass typo checks ▶

Summary

The PR rejects mistyped children of commands whose declared arguments are only flags.

  • Mistyped child words no longer run flags-only parent commands.

Reviews (1) · Last reviewed commit: "Reject a mistyped subcommand instead of ..." · Reviewed by Greptile

Comment thread bin/omarchy
Comment on lines +1072 to +1075
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @Liukskywalkerr. This fixes a real problem: on quattro, omarchy update firmwre runs a full update, as #16770 describes. But #16944, opened a day earlier, fixes the same issue the same way, so this one stays with the maintainer and won't be brought to ready.

What was checked. I read this diff and #16944's against the dispatcher in bin/omarchy. I asked the second opinion (Codex Medium) to compare the two without seeing my answer. It also picked #16944, though its independence from my reasoning isn't guaranteed. I checked the reasons below against the source. Neither branch was run on a worker for this comparison, since only one of the two fixes will be merged. #16944 has already been verified on a worker.

Why #16944. It is older, and it handles a case this branch misses, the one Greptile flagged above. Here reject_mistyped_child only looks at the first leftover word, so omarchy update -y firmwre skips the check. That passes -y firmwre to omarchy-update, which sees $1 == -y and starts the full update without the confirmation prompt. That is worse than the typo this PR guards against. #16944 skips past flags to the first bare word and rejects that. It also covers a group parent that declares no omarchy:args at all. Here command_takes_only_flags returns false for empty args, so such a parent still runs with the typo.

What carries over. Your test that a flags-only parent still takes its flag (omarchy flagparent -y) isn't covered in #16944 or on quattro. It has been marked to be folded into #16944, crediting you.

Next. Waiting on the maintainer, who chooses between the two.

@Liukskywalkerr

Copy link
Copy Markdown
Author

Closing in favor of #16944, which also handles the leading-flag case (omarchy update -y firmwre) that this branch misses. Thanks for folding the flagparent -y test into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mistyped subcommand silently runs the parent command (e.g. omarchy update firmwre runs a full update)

2 participants