Fixes · Checked on 2026-10-03
unexpected EOF while looking for matching
A coding agent writes a long script into a heredoc, sends it to Bash, and Bash says a quote was never closed. In the script, it was.
The error
bash: -c: line N: unexpected EOF while looking for matching `''
Why it happens
On Windows, Claude Code's Bash tool hands the command to the shell on a command line, and that command line is cut near 8,191 characters once the tool's own wrapper is added. Whatever comes after the cut never arrives: the closing quote, the heredoc's end marker. So Bash reports a quote that never closes.
We read the 30,450 Bash calls in our own Claude Code logs from 10 September to 1 October 2026. No command over 7,659 characters succeeded. Of the heredoc commands over 8,000 characters, all 34 failed; under 1,000 characters, 1 in 1,069 did.
The fix
Don't send long scripts through the shell. Write the script to a file with the agent's file tool (in Claude Code, the Write tool), then run the file:
python script.py
bash script.sh
A file is read as written: no command line, no length limit, no quoting. If you type commands yourself, the same
limit applies to anything you pass to bash -c from Windows.
How DMN handles it
This is the error that showed us a lesson isn't always enough. DMN had learned the fix and told Claude Code at the start of each session and after each failure, and long heredocs still failed 10 more times in three and a half days.
So dmn hook-init also installs a guard: on Windows, a Bash command of 7,500 characters or more
is stopped before it runs, with the reason and the fix. Tested on sessions after the limit was chosen, it
stopped 20 commands: 19 had failed, and one would have worked.
DMN reads your agents' past sessions on your machine. When the same error is fixed the same way in two or more of them, it keeps the fix as a one-line lesson. When the error turns up again, Claude Code is told the fix straight away, and any agent can search what earlier sessions found. How DMN keeps what agents learn.