[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

Status Fixed / completed
Maintainer reply ✓ Yes — ant-kurt
Activity 4 comments · opened Jul 23, 2025 · closed Jul 30, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

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

  1. Use the Bash tool to execute a PowerShell command on Windows
  2. Run a command like: powershell "Get-NetIPAddress -InterfaceAlias 'Ethernet 2' -AddressFamily IPv6"
  3. The tool automatically appends Unix redirection like < /dev/null or 2>/dev/null
  4. 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.

View original on GitHub ↗

4 Comments

ant-kurt collaborator · 1 year ago

This should be fixed in tomorrow's release!

benjaminjamesbush · 1 year ago

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:

# Command I instructed Claude to send:
1..15 | ForEach-Object { $_ }

# What actually got sent after transformation:
1..15 < /dev/null | ForEach-Object { $_ }

# Result: PowerShell syntax error - "<" is not a valid operator

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!

ant-kurt collaborator · 1 year ago

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.

github-actions[bot] · 1 year 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.