Skip to content

Comments

Fix ralph-loop unbound variable crash on empty PROMPT_PARTS#433

Closed
cha1mers wants to merge 1 commit intoanthropics:mainfrom
cha1mers:fix/ralph-loop-unbound-variable
Closed

Fix ralph-loop unbound variable crash on empty PROMPT_PARTS#433
cha1mers wants to merge 1 commit intoanthropics:mainfrom
cha1mers:fix/ralph-loop-unbound-variable

Conversation

@cha1mers
Copy link

Summary

  • Fixes PROMPT_PARTS[*]: unbound variable crash in setup-ralph-loop.sh when no prompt arguments are provided
  • One-line change: ${PROMPT_PARTS[*]}${PROMPT_PARTS[*]:-}

Root Cause

The script uses set -euo pipefail (line 6), and set -u treats empty bash arrays as unbound. PROMPT_PARTS=() is initialized on line 9, but ${PROMPT_PARTS[*]} on line 113 triggers the error before reaching the proper empty-prompt validation on line 116.

Test plan

# Before fix — crashes
bash -c 'set -euo pipefail; PROMPT_PARTS=(); PROMPT="${PROMPT_PARTS[*]}"; echo "$PROMPT"'
# → bash: PROMPT_PARTS[*]: unbound variable

# After fix — works, reaches validation
bash -c 'set -euo pipefail; PROMPT_PARTS=(); PROMPT="${PROMPT_PARTS[*]:-}"; echo "result: [$PROMPT]"'
# → result: []

Fixes #432

🤖 Generated with Claude Code

The script uses `set -u` (nounset) via `set -euo pipefail`, which
causes `${PROMPT_PARTS[*]}` to fail with "unbound variable" when the
array is empty. This happens when no prompt arguments are passed or
when all arguments are flags.

Adding the `:-` default operator provides an empty string fallback,
allowing the script to reach the proper empty-prompt validation.

Fixes anthropics#432

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

Thanks for your interest! This repo only accepts contributions from Anthropic team members. If you'd like to submit a plugin to the marketplace, please submit your plugin here.

@github-actions github-actions bot closed this Feb 20, 2026
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.

ralph-loop: setup script crashes with 'unbound variable' when PROMPT_PARTS is empty

1 participant