[BUG] Bash onecmd option causes npm script output to be lost on Windows
Environment
- Claude Code version: VS Code Extension (latest)
- Operating System: Windows 11
- Shell: Git Bash (via CLAUDE_CODE_GIT_BASH_PATH)
- Node version: v24.x
Bug Description
When running npm scripts (like npm run build) through Claude Code's Bash tool, the output is completely lost/invisible. The commands execute successfully but return no output to Claude.
Root Cause
Claude Code sets the bash onecmd option (equivalent to set -t) in SHELLOPTS when spawning bash processes. This option causes bash to exit after reading and executing one command.
When npm runs scripts with shebang (e.g., #!/usr/bin/env node), the onecmd option causes the parent shell to exit before the script can produce output.
Evidence:
$ echo $SHELLOPTS
braceexpand:hashall:igncr:interactive-comments:monitor:onecmd
Even spawning a fresh bash instance shows onecmd is set:
$ bash -c 'echo $SHELLOPTS'
braceexpand:hashall:igncr:interactive-comments:onecmd
Steps to Reproduce
- Open Claude Code in VS Code on Windows with Git Bash configured
- Ask Claude to run
npm run build(or any npm script that uses node) - Observe that the command completes but no output is shown
Expected Behavior
npm script output should be visible to Claude, showing compilation results, errors, etc.
Actual Behavior
Commands execute but return empty output or "no content", making it impossible to verify build success or diagnose errors.
Workaround
Prefix all bash commands with set +o onecmd;:
set +o onecmd; npm run build 2>&1
This disables the onecmd option before running the actual command.
Suggested Fix
Don't set the onecmd (-t) option when spawning bash processes, or provide a configuration option to control shell options.
Related Issues
- #5041 - Bash output not getting picked up (closed as duplicate, but root cause not identified)
- #4507 - Git Bash path issues
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗