[BUG] Claude Code's Bash tool incorrectly applies Unix-style redirection (< /dev/null, 2>/dev/null) to PowerShell commands on Windows, causing PowerShell parser errors
Environment
- Platform (select one):
- Anthropic API
- AWS Bedrock
- Google Vertex AI
- Other:
- Claude CLI version:
- Operating System: Windows 11 (MSYS_NT-10.0-26100)
- Terminal: MSYS2/Git Bash
Bug Description
Claude Code's Bash tool incorrectly applies Unix-style redirection (< /dev/null, 2>/dev/null) to PowerShell commands on Windows, causing PowerShell parser errors. The tool appears to automatically append Unix redirection syntax to
PowerShell commands, which is invalid on Windows.
Steps to Reproduce
- Use the Bash tool to execute a PowerShell command on Windows
- Run a command like: powershell "Get-NetIPAddress -InterfaceAlias 'Ethernet 2' -AddressFamily IPv6"
- The tool automatically appends Unix redirection like < /dev/null or 2>/dev/null
- PowerShell fails with parser error about '<' operator being reserved
Expected Behavior
PowerShell commands should either:
- Use Windows-appropriate redirection syntax (2>$null, >$null)
- Have no automatic redirection applied
- Detect the target shell and apply appropriate redirection syntax
Actual Behavior
Unix-style redirection is automatically appended to PowerShell commands, causing syntax errors:
Error: At line:1 char:68
- ... IPAddress -InterfaceAlias 'Ethernet 2' -AddressFamily IPv6 < /dev/nu ...
- ~
The '<' operator is reserved for future use.
- CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
- FullyQualifiedErrorId : RedirectionNotSupported
Additional Context
This occurs consistently when using the Bash tool to run PowerShell commands on Windows. The workaround is to use powershell -c "command" or powershell -ExecutionPolicy Bypass -Command "command" syntax, but the automatic redirection still sometimes gets applied incorrectly.
4 Comments
This should be fixed in tomorrow's release!
Thank you for working on this fix! I wanted to share my specific use case that was blocked by this issue.
I was building a PowerShell named pipe inter-process communication system where Claude would send PowerShell commands as strings. Any command containing pipe characters would get corrupted:
This made it impossible to send any PowerShell pipeline commands through Claude Code, forcing me to abandon the project.
Really appreciate that this is being fixed - it will unblock inter-process communication workflows that need to send shell commands containing pipes. Looking forward to the update!
Thanks for sharing your use case! FYI we ran into some issues while validating the fix, so it may be a few more days unfortunately. Will keep you updated.
UPDATE: this should be going out with tomorrow's release.
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.