Repository navigation
fix(rice-switch): cancel on Esc instead of switching and logging out - #76
Merged
Merged
Conversation
gui_menu runs in a command substitution, so its `exit 0` on Esc only left the subshell. ACTION was empty and switch_to "" went on: rices/ passed the directory check, install.sh relinked the current rice, an empty .current_rice was written and the session logged out. Stop when nothing was chosen, and reject empty or path-like rice names in switch_to. Fixes #74
Schnee111
commented
Oct 25, 2026
Schnee111
left a comment
Owner
Author
There was a problem hiding this comment.
Autonomous Code Review
Verdict: Approved
Target Commit: 217a600
Summary
Effectively fixes the session logout and rice state corruption when cancelling the menu by exiting early on empty selections and validating rice names against path traversal.
Shorekeeper Sentinel · Autonomous Quality Gate
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.
Fixes #74
What this fixes
Pressing Esc in the rice switcher menu switched and logged out instead of cancelling.
gui_menuruns inACTION="$(gui_menu)", so itsexit 0on cancel left only the subshell andACTIONcame back empty. Thenswitch_to ""went on:rices/passed the directory check;install.sh --rice ""relinked the current rice;.current_ricewas written;Approach
gui_menu, an emptyACTIONexits 0. That covers Esc, a closed menu and a row that matches nothing.switch_toaccepts only names matching^[A-Za-z0-9][A-Za-z0-9._-]*$. An empty or path-like name (../end4,.,-x) now fails withInvalid rice nameinstead of resolving torices/or outside it.statusandlistare handled before this check, so they are unchanged.tests/rice-switch.shruns every case with--dry-runand a stubrofi:Verification
bash tests/run.sh: all test files pass.shellcheckreports no new findings; the SC2015 info at line 146 is from before this change.bin/rice-switchfrommain, the test fails withesc: expected no output, the switch ran: rice-switch: dry run for '' ....Risk
Low. Only the cancel path and invalid names behave differently. Every name under
rices/matches the pattern.