[BUG] -c: line 1: unexpected EOF while looking for matching `''

Status Closed — not planned
Reported on v2.1.47
Maintainer reply None cached
Activity 15 comments · opened Feb 19, 2026 · closed Apr 23, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Hi,

None of the bash commands are working in the latest version 2.1.47, my user folder on windows contains a ' and this is not being escaped correctly. C:\Users\SeanO'Loughlin

● Bash(cd "S:/project" && dotnet test --no-restore 2>&1 | tail -100)
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

What Should Happen?

The bash commands should work.

Error Messages/Logs

● Bash(cd "S:/project" && dotnet test --no-restore 2>&1 | tail -100)
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

● Bash(cd S:/project && dotnet test --no-restore 2>&1 | tail -100)
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

● Bash(cd /s/project && dotnet test --no-restore 2>&1 | tail -100)
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

● Bash(dotnet test S:/project --no-restore 2>&1)
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

● The path with the apostrophe in the username is causing issues. Let me work around it.

● Bash(cd /s/project && dotnet test 2>&1)
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

● Bash(pushd /s/project && pwd)
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

● Bash(pwd)
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

● Bash(echo hello)
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

● Bash(echo "hello world")
  ⎿  Error: Exit code 2
     /usr/bin/bash: -c: line 1: unexpected EOF while looking for matching `''

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

Steps to Reproduce

Have a ' in your users folder name on Windows.
Install version 2.1.47 and ask claude to ls

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.45

Claude Code Version

2.1.47

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

15 Comments

github-actions[bot] · 6 months ago

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/25691
  2. https://github.com/anthropics/claude-code/issues/25628

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

seanoAvani · 6 months ago

any movement on this?

oc3eng-design · 6 months ago

Same issue here. Windows username contains an apostrophe (Irish surname) — identical unexpected EOF while looking for matching ' on every Bash tool call.

Environment:

Windows 11 Pro, Claude Code VSCode extension (latest)
Git Bash installed at C:\Program Files\Git\bin\bash.exe
Key finding — system bash works fine:

C:\> where bash
C:\Program Files\Git\bin\bash.exe

C:\> bash -c "echo hello"
hello
Claude Code ignores system PATH and uses /usr/bin/bash (WSL) regardless.

What I've tried (none worked):

Renamed WSL bash.exe in System32 and WindowsApps → still uses /usr/bin/bash
Set SHELL and CLAUDE_CODE_GIT_BASH_PATH in ~/.claude/settings.json → ignored
Downgraded CLI to v2.1.45 → same error
Added Git Bash to system PATH → system finds it, Claude Code doesn't
The Bash tool appears to hardcode /usr/bin/bash rather than respecting SHELL env var or system PATH. All other Claude Code tools (Read, Edit, Write, Grep, Glob) work fine — only the Bash tool is broken.

seanoAvani · 6 months ago
Same issue here. Windows username contains an apostrophe (Irish surname) — identical unexpected EOF while looking for matching ' on every Bash tool call. Environment: Windows 11 Pro, Claude Code VSCode extension (latest) Git Bash installed at C:\Program Files\Git\bin\bash.exe Key finding — system bash works fine: C:> where bash C:\Program Files\Git\bin\bash.exe C:> bash -c "echo hello" hello Claude Code ignores system PATH and uses /usr/bin/bash (WSL) regardless. What I've tried (none worked): Renamed WSL bash.exe in System32 and WindowsApps → still uses /usr/bin/bash Set SHELL and CLAUDE_CODE_GIT_BASH_PATH in ~/.claude/settings.json → ignored Downgraded CLI to v2.1.45 → same error Added Git Bash to system PATH → system finds it, Claude Code doesn't The Bash tool appears to hardcode /usr/bin/bash rather than respecting SHELL env var or system PATH. All other Claude Code tools (Read, Edit, Write, Grep, Glob) work fine — only the Bash tool is broken.

I have stayed on 2.1.45 which works, if i upgrade its unusable. I guess we have to wait for this to be fixed before we can use the latest.

oc3eng-design · 6 months ago

This is not a duplicate of either #25691 or #25628. While all three involve special characters in Windows usernames breaking the Bash tool, they are distinct bugs at different layers with different root causes and fixes:

| Issue | Character | Error | Root Cause | Fix Required |
|-------|-----------|-------|------------|--------------|
| #25691 | Spaces (First Last) | Permission denied (word-splitting) | Unquoted variable expansion in wrapper script | Double-quote variables |
| #25628 | Periods (user.DOMAIN) | fatal error - add_item (MSYS2 hang) | Upstream MSYS2/Cygwin path translation bug | Alternative shell support or upstream fix |
| #26742 | Apostrophes (O'Connor) | unexpected EOF while looking for matching ' | Unescaped ' in bash -c command string | Escape single quotes before interpolating paths |

Specifically, this issue occurs because the apostrophe in the username path (e.g., C:\Users\PaulO'Connor\) is a shell quote delimiter. When Claude Code interpolates this path into a bash -c '...' command, the ' terminates the string early, creating an unterminated quote — hence the unexpected EOF syntax error. Every Bash tool call fails with exit code 2.

This is a Claude Code escaping bug, not a word-splitting issue (#25691) or an MSYS2 runtime crash (#25628). Different root cause, different failure mode, different fix.

jackodonoghueqo · 6 months ago

This issue is persisting for me as well

dameeks · 5 months ago

No movement on this? @claude fix this one already. Haven't been able to update in 3 weeks.

jflheureux · 5 months ago

It looks like Claude Code stable channel is now 2.1.58 which has this bug. I installed 2.1.44 which works for me.

  1. In my C:\Users\<user_name>\.claude\settings.json file, set the following:

``
{
"env": {
"DISABLE_AUTOUPDATER": "1"
},
"minimumVersion": "2.1.44",
"autoUpdates": false
}
``

  1. From the Claude Code documentation, identified the Windows PoweShell install command:

``
irm https://claude.ai/install.ps1 | iex
``

  1. In a browser, navigated to https://claude.ai/install.ps1. It downloaded a bootstrap.ps1 script.
  2. In a PowerShell terminal in my downloads folder, ran .\bootstrap.ps1 -Target 2.1.44 to downgrade to 2.1.44.
jackodonoghueqo · 5 months ago

@claude Any update on this. Would love to use the new cowork and other feature but cannot update my claude code.

projectservan8n · 5 months ago

Still happening in 2.1.76.

Any updates on this? So frustrating.

jflheureux · 5 months ago

This issue is fixed for me in v2.1.81 (latest as I write these lines).
I think the following changelog entry in 2.1.77 is the fix:

Fixed Bash tool reporting errors for successful commands when the system temp directory path contains spaces

They likely escaped the path and fixed the issue with the apostrophe at the same time.

seanoAvani · 5 months ago
This issue is fixed for me in v2.1.81 (latest as I write these lines). I think the following changelog entry in 2.1.77 is the fix: > Fixed Bash tool reporting errors for successful commands when the system temp directory path contains spaces They likely escaped the path and fixed the issue with the apostrophe at the same time.

Yes, it appears to be fixed for me also using 2.1.81

EDIT: Actually seeing this still in some areas like hooks.

Error: PreToolUse:Write hook error: [python3 ${CLAUDE_PLUGIN_ROOT}/hooks/security_reminder_hook.py]: /usr/bin/bash: -c: line 1: unexpected EOF while looking for
     matching `''
projectservan8n · 5 months ago

It was working, until it hits hooks.

node -e "const fs=require('fs'); const c=fs.readFileSync('E:/Company/AgentChecklist/js/data/phases.js','utf8'); const idx=c.indexOf('\"id\": \"phase10\"'); const b=c.lastIndexOf('{',idx); const nl=c.lastIndexOf('\\n',b); fs.writeFileSync('/tmp/phases_top.txt',c.substring(0,nl),'utf8'); console.log('top saved, len='+c.substring(0,nl).length);":

Exit code 2
/usr/bin/bash: -c: line 10: unexpected EOF while looking for matching `''

github-actions[bot] · 4 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 4 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.