[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

Resolved 💬 4 comments Opened Jul 23, 2025 by rweijnen Closed Jul 30, 2025

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 ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗