fix: use tmpfile to avoid bash 3.2 apostrophe bug in agent launcher#262
Open
imsickofmaps wants to merge 1 commit into
Open
fix: use tmpfile to avoid bash 3.2 apostrophe bug in agent launcher#262imsickofmaps wants to merge 1 commit into
imsickofmaps wants to merge 1 commit into
Conversation
macOS ships bash 3.2 which has a lexer bug: apostrophes inside heredoc content nested within \$(...) cause a syntax error. Replace the nested heredoc pattern with a tmpfile approach (top-level heredoc + cat) for AgentAider, AgentOpenCode, and the default case. AgentAmp is unaffected as it already uses top-level stdin piping. Adds a regression test case with apostrophes in the prompt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
writeAgentLaunchergeneratesstart.shscripts using a heredoc nested inside a$(...)command substitution:macOS ships bash 3.2 (GPL2 constraint). Bash 3.2 has a known lexer bug: when scanning ahead for the closing
)", it incorrectly tracks single-quote state across the heredoc body. Any apostrophe in the prompt —today's,don't,it's— causes:This silently breaks agent launch for any task description containing an apostrophe, which is extremely common.
Fix
Replace the nested heredoc with a tmpfile approach — write the prompt via a top-level heredoc (safe on all bash versions), then read it with a plain
$(cat "$TMPFILE"):Applied to
AgentAider,AgentOpenCode, and the default case.AgentAmpis unaffected — it already uses top-level stdin piping.A regression test case with apostrophes in the prompt is included, along with assertions that non-Amp scripts use the tmpfile pattern.
A note on provenance: I'm not a Go programmer — I'm just an avid and very happy Sidecar user who hit this bug. This fix was written with Claude Code (with me pointing it at the bug report and reviewing the output). I've done my best to follow the project's patterns and test conventions, but please scrutinise the diff accordingly. Happy to iterate if anything's off.