claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Bash tool doesn't capture stdout from shell script files on Windows

Open spragginsdesigns opened this issue 3 weeks ago • 13 comments

Description

On Windows, the Bash tool does not capture stdout from shell script files. This affects all shell scripts, including npm CLI shims, custom scripts, and any executable shell script.

Environment

  • OS: Windows 11 (10.0.26200)
  • Node: v22.21.0
  • Claude Code: Started occurring around v2.1.x
  • Shell: Git Bash (MINGW64)

Reproduction Steps

# Create a simple shell script
cat > /tmp/test.sh << EOF
#!/bin/sh
echo "hello from script"
EOF
chmod +x /tmp/test.sh

# These produce NO output:
/tmp/test.sh
sh /tmp/test.sh
bash /tmp/test.sh

# But these WORK:
sh -c "echo hello"
echo "echo hello" | sh
bash -c "echo hello"

Expected Behavior

Shell script files should have their stdout captured and returned, same as inline commands.

Actual Behavior

Command Type Output Captured?
sh -c "echo hello" ✅ Yes
bash -c "echo hello" ✅ Yes
echo "cmd" | sh ✅ Yes
node /path/to/script.js ✅ Yes
/path/to/script.sh ❌ No
sh /path/to/script.sh ❌ No
bash /path/to/script.sh ❌ No

Exit code is 0 (success), but stdout is empty.

Impact

This breaks all npm CLI tools on Windows because npm creates shell shims like:

#!/bin/sh
basedir=$(dirname ...)
exec node "$basedir/node_modules/pkg/dist/main.js" "$@"

When Claude Code runs linearis, prettier, eslint, or any npm-installed CLI, no output is returned.

Workaround

Call node directly, bypassing the shell shim:

# Instead of: linearis issues read LC-123
node /c/Users/Owner/AppData/Roaming/npm/node_modules/linearis/dist/main.js issues read LC-123

Or use PowerShell wrapper:

powershell.exe -Command "linearis issues read LC-123"

Possibly Related Changelog Entries

  • v2.1.2: "Changed large bash command outputs to be saved to disk instead of truncated"
  • v2.1.0: "Added unified Ctrl+B backgrounding for both bash commands and agents"

These changes may have affected how stdout is captured from shell script file execution vs inline commands.

spragginsdesigns avatar Jan 16 '26 03:01 spragginsdesigns