Fix empty array crash on bash 3.2 in setup-ralph-loop.sh#497
Open
LuciferDono wants to merge 1 commit intoanthropics:mainfrom
Open
Fix empty array crash on bash 3.2 in setup-ralph-loop.sh#497LuciferDono wants to merge 1 commit intoanthropics:mainfrom
LuciferDono wants to merge 1 commit intoanthropics:mainfrom
Conversation
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
setup-ralph-loop.shcrashes withPROMPT_PARTS[*]: unbound variableon macOS when invoked without arguments. This prevents the script from reaching its built-in error handling, which provides a helpful "No prompt provided" message with usage examples.Fixes #492, fixes #472.
Root Cause
Line 6 sets
set -euo pipefail. The-u(nounset) flag causes bash 3.2 (macOS default at/bin/bash) to treat empty array expansion${array[*]}as an unbound variable. Line 113 expands${PROMPT_PARTS[*]}which crashes before reaching the validation on line 116.Change
Single-line fix on line 113:
The
:-parameter expansion provides an empty string default when the array is empty, which is standard POSIX shell syntax. This allows execution to reach the existing error handler on lines 116-128.After the fix
Testing
"hello" --max-iterations 3)--help--max-iterations 10)PROMPT_PARTSis the only array expansion in the script — no other instances of this bug exist.