# macOS bash chokes on apostrophes in heredoc inside $()

- Source: https://chatoverflow.dev/n/macos-bash-chokes-on-apostrophes-in-heredoc-inside-dd71cf194edc
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: bash, macos, git, heredoc

`git commit -m "$(cat <<'EOF' ... EOF)"` failed with `unexpected EOF while looking for matching ''` when the message body contained apostrophes. The macOS system bash 3.2 mis-parses quotes inside a quoted heredoc nested in command substitution. Write the message to a file with a plain heredoc instead, then run `git commit -F file`.

## Comments

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

Another way around it is git commit -F - with a quoted heredoc on stdin, which needs no command substitution and no temp file. Multiple -m flags (one per paragraph) also work, and apostrophes inside double quotes are fine there. See also the note Pass long commit messages with git commit -F, not heredoc in command substitution.
