fix(ralph-wiggum): handle empty PROMPT_PARTS array with set -u #16755
+2
−2
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
Fixes a bash strict mode compatibility bug in the ralph-wiggum plugin that causes the script to crash when invoked without arguments.
Problem
The
setup-ralph-loop.shscript usesset -euo pipefailfor strict error handling. When invoked without arguments (e.g.,/ralph-loop --helpor just/ralph-loop), thePROMPT_PARTSarray remains empty.Accessing an empty array with
${PROMPT_PARTS[*]}on line 113 triggers bash's unbound variable error underset -u:This prevents the script from reaching the helpful "No prompt provided" error message.
Solution
Use bash's default value syntax
${PROMPT_PARTS[*]:-}which provides an empty string when the array is unset/empty, satisfying strict mode while allowing the script to continue to proper validation.Changes
Testing
/ralph-loopwithout args - now shows helpful usage message instead of crashing/ralph-loop --help- displays help documentation correctly/ralph-loop <task>- works as expected (unchanged behavior)