[BUG] Bash tool fails to capture stdout from shell scripts on Windows MINGW/Git Bash
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?
Shell scripts executed via the Bash tool produce no captured output on Windows when running under MINGW/Git Bash. The scripts execute successfully (exit code 0), but stdout/stderr are not captured. This is a regression - it was working correctly in previous versions of Claude Code.
Environment
- OS: Windows 11 (MINGW64_NT-10.0-26100)
- Shell: GNU bash 5.2.37(1)-release (x86_64-pc-msys) / Git Bash
- Node.js: v22.17.0
- MSYS Version: 3.6.5-22c95533.x86_64
Actual Behavior
- Scripts with shebang (#!/bin/sh or #!/bin/bash) execute but output is lost
- Exit code is captured correctly (returns 0)
- Tool reports "Tool ran without output or errors"
What Works vs What Doesn't
┌──────────────────────────────────┬────────┐
│ Execution Type │ Works? │
├──────────────────────────────────┼────────┤
│ .cmd / .bat files │ ✅ Yes │
├──────────────────────────────────┼────────┤
│ Inline commands (echo "test") │ ✅ Yes │
├──────────────────────────────────┼────────┤
│ Command substitution ($(...)) │ ✅ Yes │
├──────────────────────────────────┼────────┤
│ Subshells ((echo "test")) │ ✅ Yes │
├──────────────────────────────────┼────────┤
│ Piped commands (echo "x" | cat) │ ✅ Yes │
├──────────────────────────────────┼────────┤
│ Shell scripts (./script.sh) │ ❌ No │
├──────────────────────────────────┼────────┤
│ Explicit bash (bash script.sh) │ ❌ No │
├──────────────────────────────────┼────────┤
│ Scripts via PATH (mvn --version) │ ❌ No │
└──────────────────────────────────┴────────┘
What Should Happen?
Shell script output should be captured and displayed, as it was in previous versions.
Error Messages/Logs
Steps to Reproduce
- Run Claude Code on Windows using Git Bash/MINGW
- Execute a shell script that has a shebang (e.g., mvn --version)
- Observe that the tool reports "Tool ran without output or errors" despite the command producing output
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.14 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
Workaround
On Windows, use .cmd equivalents when available (e.g., mvn.cmd instead of mvn).
Additional Context
This appears to be related to how MINGW handles fork/exec of scripts with shebangs. The subprocess runs correctly but its stdout is not being
captured by the Bash tool. On native Linux, this works as expected.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗