[BUG] Claude likes to use 2>&1 in Bash commands, and it doesn't work if piped to grep

Resolved 💬 3 comments Opened Aug 12, 2025 by werdnum Closed Aug 15, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.73
  • Operating System: Ubuntu 22.04
  • Terminal: all

Bug Description

Claude likes to run pytest my_file.py 2>&1, but when it does, 2 is interpreted as an argument to pytest, causing Claude to go down a rabbit hole of trying to figure out why test collection is failing.

Steps to Reproduce


What's new:                                                                           │
│  • MCP: Support multiple config files with `--mcp-config file1.json file2.json`       │
│  • MCP: Press Esc to cancel OAuth authentication flows                                │
│  • Bash: Improved command validation and reduced false security warnings              │
│  • UI: Enhanced spinner animations and status line visual hierarchy                   │
│  • Linux: Added support for Alpine and musl-based distributions (requires separate    │
│  ripgrep installation)                                                                │
│                                                                                       │
│> Please run the command 'echo foo 2>&1'                                               │
│                                                                                       │
│● I'll run that command for you.                                                       │
│                                                                                       │
│● Bash(echo foo 2>&1)                                                                  │
│  ⎿  foo                                                                               │
│                                                                                       │
│● The command executed successfully and output: foo                                    │
│  ⎿  Interrupted by user                                                               │
│                                                                                       │
│> hmm, try piping to grep foo                                                          │
│                                                                                       │
│● I'll pipe the echo command to grep to search for "foo".                              │
│                                                                                       │
│● Bash(echo foo 2>&1 | grep foo)                                                       │
│  ⎿  foo 2

Expected Behavior

Output should be foo

Actual Behavior

Output is foo 2

Additional Context

That bash command validation entry in what's new sure sounds suspicious.

View original on GitHub ↗

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