Skip to content

ralph-loop: Bash unbound variable error in setup-ralph-loop.sh #301

@hanzili

Description

@hanzili

Bug Description

The setup-ralph-loop.sh script fails with an unbound variable error when set -u (strict mode) is enabled and no prompt arguments are provided before options.

Error

PROMPT_PARTS[*]: unbound variable

Root Cause

Line 113 in scripts/setup-ralph-loop.sh:

PROMPT="${PROMPT_PARTS[*]}"

When PROMPT_PARTS array is empty (e.g., when only options like --help are passed, or in certain edge cases), bash's strict mode (set -u on line 6) causes this to fail.

Fix

Change line 113 from:

PROMPT="${PROMPT_PARTS[*]}"

To:

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

The :-} provides a default empty string when the array is empty, preventing the unbound variable error while maintaining strict mode for catching other bugs.

Environment

  • macOS (Darwin 25.1.0)
  • Bash (zsh-compatible)
  • Claude Code CLI

Steps to Reproduce

  1. Install the ralph-loop plugin
  2. Run /ralph-loop --help or any command that might result in an empty PROMPT_PARTS array
  3. Observe the unbound variable error

The fix is a one-line change that maintains backward compatibility.

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