Skip to content

fix: escape single quotes for bash 3.2 in start scripts#225

Open
jennings wants to merge 1 commit intomarcus:mainfrom
jennings:jennings/xsrztzkswusp
Open

fix: escape single quotes for bash 3.2 in start scripts#225
jennings wants to merge 1 commit intomarcus:mainfrom
jennings:jennings/xsrztzkswusp

Conversation

@jennings
Copy link

@jennings jennings commented Mar 3, 2026

When a task description contains a single quote, the current pattern
claude "$(cat <<'SIDECAR_PROMPT_EOF' ... fails on macOS with the
error:

/path/to/start.sh: line 16: unexpected EOF while looking for matching `''
/path/to/start.sh: line 22: syntax error: unexpected end of file

macOS ships with bash 3.2 which contains a bug that parses the current
pattern incorrectly.

To ensure the script works on macOS, use read to read the heredoc into
a variable first, then use the variable when launching the agent.

Before:

claude "$(cat <<'SIDECAR_PROMPT_EOF'
This single quote causes the bash error: '
SIDECAR_PROMPT_EOF
)"

After:

read -r -d '' sidecar_prompt <<'SIDECAR_PROMPT_EOF'
This single quote is now okay: '
SIDECAR_PROMPT_EOF
claude "$sidecar_prompt"

@jennings jennings force-pushed the jennings/xsrztzkswusp branch from 77a16d0 to ea8fdb9 Compare March 3, 2026 06:57
@jennings jennings changed the title fix: fix start script when task contains a single quote fix: escape single quotes correctly in start scripts Mar 3, 2026
@jennings jennings force-pushed the jennings/xsrztzkswusp branch from ea8fdb9 to 9c06a29 Compare March 3, 2026 07:03
When a task description contains a single quote, the current pattern
`claude "$(cat <<'SIDECAR_PROMPT_EOF' ...` fails on macOS with the
error:

```
/path/to/start.sh: line 16: unexpected EOF while looking for matching `''
/path/to/start.sh: line 22: syntax error: unexpected end of file
```

macOS ships with bash 3.2 which contains a bug that parses the current
pattern incorrectly.

To ensure the script works on macOS, use `read` to read the heredoc into
a variable first, then use the variable when launching the agent.

Before:

```sh
claude "$(cat <<'SIDECAR_PROMPT_EOF'
This single quote causes the bash error: '
SIDECAR_PROMPT_EOF
)"
```

After:

```sh
read -r -d '' sidecar_prompt <<'SIDECAR_PROMPT_EOF'
This single quote is now okay: '
SIDECAR_PROMPT_EOF
claude "$sidecar_prompt"
```
@jennings jennings force-pushed the jennings/xsrztzkswusp branch from 9c06a29 to 46c26bb Compare March 3, 2026 07:04
@jennings jennings changed the title fix: escape single quotes correctly in start scripts fix: escape single quotes for bash 3.2 in start scripts Mar 3, 2026
@marcus
Copy link
Owner

marcus commented Mar 3, 2026

Hey @jennings! Starling here (AI assistant on the project). 👋

This is a great catch — the bash 3.2 heredoc bug has probably been silently biting macOS users with single quotes in their task descriptions for a while. The fix is clean and the commit message is excellent (clear before/after, explains why the old pattern fails on macOS).

A few quick observations on the change:

  • read -r -d '' is the canonical bash 3.2–compatible workaround for this exact issue
  • ✅ Single file, minimal diff — exactly the right scope for a bug fix
  • ✅ The || true handling is preserved correctly

Passing this up for Marcus to review and merge. Thanks for taking the time to dig into this! ✦

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.

2 participants