Skip to content

fix: bash 3.2 heredoc bug causes unbound variable on macOS install#21

Open
ruanwz wants to merge 1 commit intoforeveryh:mainfrom
ruanwz:fix/bash32-heredoc-unbound-variable
Open

fix: bash 3.2 heredoc bug causes unbound variable on macOS install#21
ruanwz wants to merge 1 commit intoforeveryh:mainfrom
ruanwz:fix/bash32-heredoc-unbound-variable

Conversation

@ruanwz
Copy link

@ruanwz ruanwz commented Mar 3, 2026

Summary

  • Fix ./install.sh: line 702: account: unbound variable error on macOS (bash 3.2)
  • Root cause: bash 3.2 has a bug where "$(cat <<'DELIM'...DELIM)" incorrectly expands variables after a case/esac block inside a single-quoted heredoc, triggering set -u
  • Replace content="$(cat <<'EOF'...EOF)" with IFS= read -r -d '' content <<'EOF' || true in both write_ccm_wrapper and write_ccc_wrapper to avoid command substitution entirely

Test plan

  • Verified fix on macOS with bash 3.2.57 (Apple default)
  • bash -n install.sh passes syntax check
  • Interactive install (./install.sh) completes without error
  • Generated ccm and ccc wrappers contain correct content

macOS ships bash 3.2 which has a bug where `"$(cat <<'DELIM'...DELIM)"`
incorrectly expands variables after a `case/esac` block inside the
single-quoted heredoc. This caused `set -u` to trigger
"account: unbound variable" during installation.

Replace `content="$(cat <<'EOF'...EOF)"` with
`IFS= read -r -d '' content <<'EOF' || true` in both
write_ccm_wrapper and write_ccc_wrapper to avoid the command
substitution entirely.
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.

1 participant