Skip to content

Fix ralph-loop crash when invoked without arguments#30537

Open
Danlobaton wants to merge 1 commit intoanthropics:mainfrom
Danlobaton:fix/ralph-loop-unbound-variable
Open

Fix ralph-loop crash when invoked without arguments#30537
Danlobaton wants to merge 1 commit intoanthropics:mainfrom
Danlobaton:fix/ralph-loop-unbound-variable

Conversation

@Danlobaton
Copy link
Copy Markdown

Summary

Fixes the PROMPT_PARTS[*]: unbound variable crash in the ralph-loop plugin when invoked without arguments (/ralph-loop).

Closes #18496

Changes

  • plugins/ralph-wiggum/scripts/setup-ralph-loop.sh: Changed ${PROMPT_PARTS[*]} to ${PROMPT_PARTS[*]:-} on line 113 to provide a default empty string when the array is empty

Root Cause

The script uses set -euo pipefail (line 6), which enables set -u (treat unset variables as errors). When /ralph-loop is called with no arguments, PROMPT_PARTS remains an empty array. On bash 3.2 (macOS default), referencing ${PROMPT_PARTS[*]} on an empty array triggers an "unbound variable" error, crashing the script before it can reach the "No prompt provided" validation message on line 116.

Testing

Verified both cases with bash under set -euo pipefail:

# Empty array (the bug case) — now returns empty string instead of crashing
$ bash -c 'set -euo pipefail; A=(); echo "${A[*]:-}"'
# (empty output, exit 0)

# Non-empty array — still joins correctly
$ bash -c 'set -euo pipefail; A=("hello" "world"); echo "${A[*]:-}"'
hello world

🤖 Generated with Claude Code

Fixes anthropics#18496

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ralph-loop plugin

1 participant