Repository navigation
fix(argv): -h/--help intercept on cmd_part (was actually parting on --help) - #236
Merged
Merged
Conversation
…--help Same anti-pattern as #231 fixed for cmd_send / cmd_kick / cmd_whois, missed in cmd_part. Found the hard way 2026-04-28 by airc-96dd during follow-up testing: ran 'airc part --help' to check the help text, the --help fell through, cmd_part treated it as "no specific channel" and parted the current room — disconnecting the monitor. ## Fix cmd_rooms.sh::cmd_part: case statement intercepting -h / --help BEFORE ensure_init or any state mutation. Prints usage describing the host vs joiner branches. ## Verification bash -n: clean Manual: 'airc part --help' / 'airc part -h' both print usage without touching scope state. test/integration.sh tabs: 19/0 ✓ test/integration.sh room: 14/0 ✓ Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Fixes a CLI UX/safety bug where airc part --help (or -h) would fall through argument parsing and actually execute a /part, mutating state and disconnecting the monitor.
Changes:
- Add an early
-h|--helpintercept incmd_part()beforeensure_init/ state mutation. - Print
cmd_partusage text and exit cleanly when help is requested.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| echo "Usage:" | ||
| echo " airc part leave the current channel (host's gist deleted if you're host)" | ||
| echo " (joiner: just local teardown; host's gist stays for others)" | ||
| echo " airc part --no-teardown clear room state but don't kill the airc process" |
Comment on lines
+193
to
+206
| # Help-flag intercept BEFORE ensure_init / state mutation. Without | ||
| # this, `airc part --help` (and `-h`) fell through and ACTUALLY | ||
| # PARTED the user's current room — found the hard way 2026-04-28 | ||
| # by airc-96dd while exercising the --help-intercept follow-up | ||
| # work from #231. Same anti-pattern as the cmd_send/kick/whois | ||
| # bugs that #231 already fixed; cmd_part was missed. | ||
| case "${1:-}" in | ||
| -h|--help) | ||
| echo "Usage:" | ||
| echo " airc part leave the current channel (host's gist deleted if you're host)" | ||
| echo " (joiner: just local teardown; host's gist stays for others)" | ||
| echo " airc part --no-teardown clear room state but don't kill the airc process" | ||
| return 0 ;; | ||
| esac |
joelteply
added a commit
that referenced
this pull request
Apr 28, 2026
…ep) (#237) fix(argv): -h/--help intercept on all remaining cmd_X — class-wide sweep Verb-fuzz from vhsm-d1f4 + continuum-b741 + ideem-local-4bef on 2026-04-28 caught the same anti-pattern as #231/#236 in additional verbs: DESTRUCTIVE on --help (mutated state): airc away --help → set status to "--help" airc reminder --help → wrote "--help" as the reminder interval airc channel --help → set channel preference to "--help" (would brick next 'airc update'!) NON-DESTRUCTIVE but no help text: airc status --help, airc connect --help, airc teardown --help, airc daemon --help, airc doctor --help, airc update --help ## Fix Class-wide sweep: every cmd_X (and key helpers) now intercepts -h/--help BEFORE state mutation and prints a real usage block. Also added defense-in-depth in cmd_channel and cmd_reminder: - cmd_channel: refuses any flag-shaped value (case "$target" in -*) - cmd_reminder: refuses non-numeric arg (catches --foo, --bar etc) These guard against the same class of bug for flags we don't enumerate. ## Coverage After this PR: every cmd_X in lib/airc_bash/ has a -h/--help intercept. Audit: `for f in lib/airc_bash/cmd_*.sh; do grep -qE -- "-h\\|--help" "$f" || echo "MISSING: $f"; done` returns nothing. ## Verification bash -n on all 8 changed files: clean Manual: airc {reminder,channel,away,connect,doctor,daemon,update,status, teardown} --help all print usage; none mutate. test/integration.sh tabs: 19/0 ✓ test/integration.sh room: 14/0 ✓ test/integration.sh general_sidecar_default: 10/0 ✓ test/integration.sh away: 5/0 ✓ ## Bug pattern + future hardening The recurring shape: bash function takes positional arg, doesn't validate it, writes it to a state file as the new value. Anyone running `cmd --help` expecting usage gets state mutation instead. Three fixes share design: 1. -h/--help intercept BEFORE any state-touching code 2. Reject flag-shaped tokens (-*) when the value should be a name/number 3. Default action prints help, not "save whatever was passed" Worth porting (1) + (2) to airc.ps1 too — same shape, untested. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same anti-pattern as #231 fixed for cmd_send/kick/whois, missed in cmd_part. 'airc part --help' was actually executing /part and disconnecting the monitor. Now intercepts -h/--help before state mutation.
Verification: tabs 19/0, room 14/0; manual.