Preflight Checklist
What's Wrong?
What's Wrong?
Single quotes inside a bash heredoc body cause a parsing error. A << 'EOF' heredoc is supposed to pass its entire body as a literal string with no substitution or escaping. Single quotes inside the body should be inert. Instead, the Bash tool fails with a shell quoting error.
What Should Happen?
The content between << 'EOF' and EOF should be passed to the command completely literally. Single quotes, backticks, and dollar signs inside the heredoc body should have no special meaning.
Error Messages/Logs
/usr/bin/bash: -c: line 12: unexpected EOF while looking for matching `''
/usr/bin/bash: -c: line 14: syntax error: unexpected end of file
Steps to Reproduce
In the Bash tool, run the following command:
cat > /tmp/test.ps1 << 'EOF'
$lines = @()
$lines += 'hello world'
Write-Host $lines
EOF
The command fails at the line containing single quotes inside the heredoc body
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
No response
Claude Code Version
latest
Platform
Other
Operating System
Windows
Terminal/Shell
Other
Additional Information
The root cause appears to be that the Bash tool passes commands to the shell as a single-quoted -c argument: bash -c '...'. When the command string itself contains single quotes (even inside a heredoc body), those quotes prematurely close the outer -c quoting, breaking the parse. Heredocs with no single quotes in the body work correctly. The workaround is to replace all single-quoted strings in the heredoc content with double-quoted strings. A proper fix would be to pass commands to the shell via stdin or using ANSI-C quoting ($'...') rather than wrapping in single quotes.
Preflight Checklist
What's Wrong?
What's Wrong?
Single quotes inside a bash heredoc body cause a parsing error. A << 'EOF' heredoc is supposed to pass its entire body as a literal string with no substitution or escaping. Single quotes inside the body should be inert. Instead, the Bash tool fails with a shell quoting error.
What Should Happen?
The content between << 'EOF' and EOF should be passed to the command completely literally. Single quotes, backticks, and dollar signs inside the heredoc body should have no special meaning.
Error Messages/Logs
Steps to Reproduce
In the Bash tool, run the following command:
cat > /tmp/test.ps1 << 'EOF'
$lines = @()
$lines += 'hello world'
Write-Host $lines
EOF
The command fails at the line containing single quotes inside the heredoc body
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
No response
Claude Code Version
latest
Platform
Other
Operating System
Windows
Terminal/Shell
Other
Additional Information
The root cause appears to be that the Bash tool passes commands to the shell as a single-quoted -c argument: bash -c '...'. When the command string itself contains single quotes (even inside a heredoc body), those quotes prematurely close the outer -c quoting, breaking the parse. Heredocs with no single quotes in the body work correctly. The workaround is to replace all single-quoted strings in the heredoc content with double-quoted strings. A proper fix would be to pass commands to the shell via stdin or using ANSI-C quoting ($'...') rather than wrapping in single quotes.