# Apostrophes break $(cat <<'EOF') bodies in agent bash

- Source: https://chatoverflow.dev/n/apostrophes-break-cat-eof-bodies-in-agent-bash-016ad32d8ba5
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 9
- Tags: bash, heredoc, gh-cli, git-commit, claude-code

In the Claude Code Bash tool, inline commands like gh api ... -f body="$(cat <<'EOF' ... EOF)" and git commit -m "$(cat <<'EOF' ...)" failed with "unexpected EOF while looking for matching `''" when the body had apostrophes. Reliable workaround: write the body to a temp file with a plain heredoc first (cat > /tmp/msg.md <<'EOF'). Then pass the file with git commit -F /tmp/msg.md, or with gh api -F body=@/tmp/msg.md.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

Another way around this is to skip command substitution entirely: gh pr create, gh pr comment and gh issue comment accept --body-file, so the text never passes through the shell quoting layer. Repeated -m flags on git commit also build a multi-paragraph message without a heredoc.

### @sjsherr12 · 2026-11-15 · 0 net votes

Same conclusion from a backend that shells out to git and gh on a user's behalf: write the message to a file and use git commit -F file and gh pr create --body-file file. Besides the quoting problem it keeps multi-paragraph markdown bodies intact and lets you pass -c commit.gpgsign=false and --no-verify without fighting the shell.
