Boternal
Boternal Field Notes · Issue #2 · 2026-11-28

The shell command that never ran

Above about 7 KB, our agents' shell commands on Windows did nothing at all, and the error blamed a quote that wasn't ours. We went through 29,012 calls to find the line.

Last issue was about a process probe that pressed Ctrl+C on our whole console. This one is quieter. Nothing crashes and nothing dies. A command just doesn't run, and the error message sends you looking in the wrong place.

The symptom: a quoting error in a command with no quoting problem

Our agents run shell commands through the Bash tool in Claude Code. On our Windows machines that means Git Bash. Most of the time it's unremarkable.

Every so often, though, a command came back with this:

/usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

That reads like an ordinary mistake: a stray apostrophe, an unclosed string. So the obvious move is to go hunting for the unbalanced quote. The trouble was that the commands it showed up on didn't have one. They were often long, they often wrote a whole file through a heredoc, and their quoting was fine.

There was a second oddity. A real quoting bug usually fails partway through, after something has already run. These failures had no side effects at all. If a command started with an echo, the echo never printed. No file was written, not even a partial one.

What the isolation told us

"Line 1" was the clue we should have taken more seriously. Our commands didn't have a quoting problem on line 1. Something else did.

So we stopped reading individual failures and built a probe. We wrote a command about 9 KB long with echo markers spread all the way through it, one on the very first line, more at intervals down to the end. If bash were stopping partway, we'd see the markers up to the point where it stopped.

It printed zero markers. Not even the first one.

That changes the question. Bash wasn't choking on something in the middle of the command. It never got to run any of it. Whatever went wrong happened before bash started, and the only thing that distinguished the failing commands was that they were big.

The cause: a command line with a ceiling

To run a Bash tool command on Windows, the harness wraps it like this:

bash -c '<your command>'

and hands that whole string to Windows as a process command line. That goes through cmd.exe, and cmd.exe caps a command line at 8,191 characters.

When the wrapped command is over the cap, the tail gets cut off. The tail is where the wrapper's own closing quote lives. So bash receives a -c argument whose opening ' has no partner, and it reports, accurately, that on line 1 it hit the end of input while looking for a matching quote.

The quote it's complaining about is the wrapper's, not yours. Line 1 is the wrapper's line 1. And since bash refuses to run a script that doesn't parse, nothing executes. The command isn't truncated mid-run. It's dropped whole.

How we found the real line

Knowing the theoretical cap is 8,191 wasn't enough to work with, because the number that counts isn't the size of your command. It's the size of everything on that command line, wrapper included.

So we measured it. Our agents' session transcripts record every tool call, which gave us 29,012 Bash calls to look through. We bucketed them by command size and checked which ones failed with that error. Two buckets tell the whole story:

Command size Calls Failure rate
7,788 bytes or less 2,328 about 0.2%
7,900 bytes or more 33 100%

The 0.2% below the line were genuine quoting bugs, the kind the error message is actually describing. Above the line, every single call failed. All 33.

The edge itself wasn't clean. A 7,788-byte command went through, and a 7,754-byte one failed. A smaller command failing where a larger one passed is what you'd expect if the limit includes overhead the wrapper adds, not just the bytes you wrote. That's the real lesson of the boundary: you can't sit right under 8,191 and count on it.

So our working budget is about 7,000 bytes per command, not 8,191. It leaves enough headroom that the wrapper's overhead never decides the outcome.

Why it hid

Three things kept this out of sight:

  1. The error blames you. "Unexpected EOF while looking for matching quote" is a message every shell user has earned honestly at some point. It points at your quoting, and it's right about 0.2% of the time. The rest of the time it's describing a quote you never wrote.
  2. There's no partial output to follow. Most bugs leave a trail: the first half ran, so you look at the second half. This one leaves nothing. The command looks exactly as if it had never been sent, which, as far as bash is concerned, it wasn't.
  3. It looked like a heredoc problem. The commands that crossed the line were usually heredocs, because inlining a whole file into one command is the easiest way to make a command large. So heredocs took the blame. But heredocs aren't the bug. Under about 7 KB, every heredoc form we use works: plain <<EOF, the quoted <<'EOF' form, and a heredoc piped into Python. They're just the most common way to hit the ceiling.

The fix: don't send big things through the command line

Once the cause is clear, the fixes are boring, which is how we like them:

While we were in there, we wrote down the three heredoc mistakes that are real, so they stop getting confused with the size limit:

The part that matters for agents

A person who hits this once will probably shrug, split the command, and move on. An agent is more likely to take the error message at its word. "Unmatched quote" invites a quoting fix, and a quoting fix leaves the command the same size, so it goes straight back to the same ceiling. Nothing in the error says size is the problem, so there's nothing to steer the next attempt toward making it smaller.

Agents also hit this more than people do. A person rarely types an 8 KB shell command. An agent writing a file through a heredoc produces one without noticing, because to the agent the file contents and the command are the same thing.

So the fix went where the agents would see it: into the short "Windows shell gotchas" rules file they load at the start of every session. The entry says what the error looks like, that "line 1" means the wrapper's line, that nothing ran, and the 7,000-byte budget. It lists the fixes in order of preference. It also says plainly that heredocs aren't the bug, because without that line the natural over-correction is "never use heredocs", which throws away a tool that works fine below the limit.

The other lesson is about how we found it. Each failure on its own looked like a quoting problem. What settled it was the probe, which proved the command never started, and the measurement, which turned "big commands seem to fail" into a line we could put a number on. The transcripts were already there. All it took was asking them the question. If your agents keep logs of their tool calls, they're probably holding the answer to a few of your "flaky" failures too.

If you only take one thing

On Windows, if a Bash tool command fails with an unmatched-quote error on line 1, check its size before you check its quotes. Over about 7,000 bytes, nothing ran. Use the Write tool for the file instead.

Next issue: a deletion guard for agents that stopped crying wolf. Asking before every delete trained everyone to click Allow, and the fix was making most deletes silent and a few impossible.

Reply to this email if you've hit something like this. We read every reply.


Get the next one by email: subscribe to Boternal Field Notes.