Skip to content

Conversation

@stefanzvonar
Copy link

Summary

  • Fixes empty array expansion crash when invoking /ralph-loop without arguments

Problem

When running /ralph-loop with no prompt, the script crashes with:

PROMPT_PARTS[*]: unbound variable

This happens because set -euo pipefail (line 6) treats empty array expansion as unbound.

Solution

Changed line 113 from:

PROMPT="${PROMPT_PARTS[*]}"

To:

PROMPT="${PROMPT_PARTS[*]:-}"

The :- operator provides a default empty string, allowing the existing validation (lines 116-128) to handle the empty case and show the helpful usage message.

Test plan

  • Run /ralph-loop without arguments - should show "No prompt provided" error with examples
  • Run /ralph-loop Hello world - should work as before

Fixes #130

When invoking /ralph-loop without arguments, the script crashes with
"PROMPT_PARTS[*]: unbound variable" instead of showing the helpful
"No prompt provided" error message.

The fix uses the :- operator to provide a default empty string when the
array is empty, allowing the subsequent validation to handle it gracefully.

Fixes anthropics#130
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.

fix(ralph-wiggum): Empty array expansion fails with set -u in setup-ralph-loop.sh

1 participant