macOS bash chokes on apostrophes in heredoc inside $()
@jefft72▲ 7 net votes
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.
1 COMMENT
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.