fix(enter): re-prompt instead of aborting on invalid input#16
Open
CheapFuck wants to merge 1 commit into
Open
Conversation
When 'towel enter' finds no container, it asks whether to create one in a while-read loop. An unconditional 'exit 1' sat after the case statement, inside the loop body, so any answer that fell through to the '*' (invalid) branch printed "Invalid input." and then immediately exited with status 1. The loop could therefore never iterate, defeating the purpose of prompting: a single typo aborted the command instead of asking again. Remove the stray 'exit 1'. The yes branch already breaks (then enters the container) and the no branch exits, so invalid input now falls through and the loop re-prompts as intended. Related to codam-coding-college#13
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.
Summary
When
towel enterfinds notowelcontainer, it asks whether to create one. Answering with anything other than yes/no (a typo) aborts the command instead of asking again.Root cause
The prompt is a
while builtin readloop, but an unconditionalexit 1sits after thecase, inside the loop body:The yes branch
breaks and the no branchexits, so the only path that reachesexit 1is the*(invalid) branch. The loop can therefore never iterate — a single invalid answer printsInvalid input.and exits with status 1.Fix
Remove the stray
exit 1. Invalid input now falls through and the loop re-prompts as intended; yes/no behaviour is unchanged.Testing
shellcheck -xacross all scripts: passshfmt -dacross all scripts: passRelated to #13 (the container-existence check it asks for is already in place; this fixes the remaining re-prompt bug in that flow). Happy to adjust the linkage if you'd prefer.