Skip to content

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

@cha1mers

Description

@cha1mers

Bug

The ralph-loop plugin's scripts/setup-ralph-loop.sh crashes on line 113 with:

PROMPT_PARTS[*]: unbound variable

Root Cause

The script uses set -euo pipefail (line 6), which includes set -u (nounset). On line 9, PROMPT_PARTS=() initializes an empty array, but on line 113:

PROMPT="${PROMPT_PARTS[*]}"

In bash, expanding an empty array with set -u triggers unbound variable. This happens both when no arguments are passed AND when all arguments are flags (e.g., --max-iterations 5).

Fix

Change line 113 from:

PROMPT="${PROMPT_PARTS[*]}"

to:

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

The :- default operator provides an empty string fallback, allowing the script to reach the proper empty-prompt validation on line 116.

Repro

  1. Install the ralph-loop plugin
  2. Run /ralph-loop (no arguments)
  3. Script crashes instead of showing the usage help

Environment

  • macOS (bash 3.2 — Apple default)
  • Claude Code with official plugins marketplace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions