Skip to content

Commit 77a16d0

Browse files
committed
fix: fix start script when task contains a single quote
When a task description contains a single quote, the current pattern `claude "$(cat <<'SIDECAR_PROMPT_EOF' ...` fails 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 ``` Instead, 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" ```
1 parent 5809466 commit 77a16d0

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

internal/plugins/workspace/agent.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -498,22 +498,22 @@ fi
498498
// aider uses --message flag
499499
script = fmt.Sprintf(`#!/bin/bash
500500
%s
501-
%s --message "$(cat <<'SIDECAR_PROMPT_EOF'
501+
read -r -d '' sidecar_prompt <<'SIDECAR_PROMPT_EOF'
502502
%s
503503
SIDECAR_PROMPT_EOF
504-
)"
504+
%s --message "$sidecar_prompt"
505505
rm -f %q
506-
`, shellSetup, baseCmd, prompt, launcherFile)
506+
`, shellSetup, prompt, baseCmd, launcherFile)
507507
case AgentOpenCode:
508508
// opencode uses 'run' subcommand
509509
script = fmt.Sprintf(`#!/bin/bash
510510
%s
511-
%s run "$(cat <<'SIDECAR_PROMPT_EOF'
511+
read -r -d '' sidecar_prompt <<'SIDECAR_PROMPT_EOF'
512512
%s
513513
SIDECAR_PROMPT_EOF
514-
)"
514+
%s run "$sidecar_prompt"
515515
rm -f %q
516-
`, shellSetup, baseCmd, prompt, launcherFile)
516+
`, shellSetup, prompt, baseCmd, launcherFile)
517517
case AgentAmp:
518518
// amp requires piping via stdin, does not accept positional args
519519
script = fmt.Sprintf(`#!/bin/bash
@@ -527,12 +527,12 @@ rm -f %q
527527
// Most agents (claude, codex, gemini, cursor) take prompt as positional argument
528528
script = fmt.Sprintf(`#!/bin/bash
529529
%s
530-
%s "$(cat <<'SIDECAR_PROMPT_EOF'
530+
read -r -d '' sidecar_prompt <<'SIDECAR_PROMPT_EOF'
531531
%s
532532
SIDECAR_PROMPT_EOF
533-
)"
533+
%s "$sidecar_prompt"
534534
rm -f %q
535-
`, shellSetup, baseCmd, prompt, launcherFile)
535+
`, shellSetup, prompt, baseCmd, launcherFile)
536536
}
537537

538538
if err := os.WriteFile(launcherFile, []byte(script), 0700); err != nil {

0 commit comments

Comments
 (0)