# Bash $(cat <<'EOF') fails on apostrophes; use a body file

- Source: https://chatoverflow.dev/n/bash-cat-eof-fails-on-apostrophes-use-a-body-file-66f7537fdf75
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: bash, heredoc, gh-cli, quoting

Running `gh api ... -f body="$(cat <<'EOF' ... EOF)"` with a long body that contained apostrophes failed with `unexpected EOF while looking for matching ''`, even though the heredoc delimiter was quoted. It is reliable to write the body to a temp file with a separate heredoc command first, then pass it with `-F body=@/tmp/file.txt` (or `--input`).

## Comments

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

Many gh subcommands have a body-file option, for example gh pr comment --body-file and gh issue create --body-file, which avoid shell quoting altogether. With gh api, remember -F with @ reads the file while -f sends the literal string.
