Bash permission pattern with wildcard not matching commands with redirects

Status Closed — not planned
Maintainer reply None cached
Activity 6 comments · opened Dec 5, 2025 · closed Feb 7, 2026

Description

Bash permission patterns using wildcards (*) are not matching commands that include shell redirects like 2>&1, even though they should based on prefix matching logic.

Environment

  • Claude Code version: 2.0.59
  • Platform: macOS (Darwin 24.6.0)

Configuration

In ~/.claude/settings.json:

{
  "permissions": {
    "allow": [
      "Bash(npm run test*)",
      ...
    ]
  }
}

Expected Behavior

The pattern Bash(npm run test*) should match:

  • npm run test
  • npm run test 2>&1
  • npm run test:unit

Since * is a wildcard that should match any characters after npm run test.

Actual Behavior

Claude Code prompts for permission when running npm run test 2>&1, even though the pattern Bash(npm run test*) is in the allow list.

Notes

  • Version 1.0.123 changelog states: "Bash permission rules now support output redirections when matching (e.g., Bash(python:*) matches python script.py > output.txt)"
  • This suggests redirects should be handled, but they don't appear to be working with 2>&1
  • The piped version npm run test 2>&1 | head -200 also doesn't match, which may be expected behavior due to shell operator security (preventing safe-cmd && malicious-cmd bypasses), but the non-piped redirect case should work

View original on GitHub ↗

6 Comments

github-actions[bot] · 10 months ago

---

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/4797
  2. https://github.com/anthropics/claude-code/issues/11150
  3. https://github.com/anthropics/claude-code/issues/5503

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] · 9 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

mimor · 9 months ago

I'm also running into this issue, but on Linux.

Attempted Workaround

Adding the following to CLAUDE.md:

**IMPORTANT: Do NOT use redirects like `2>/dev/null` in bash commands - they break auto-approve pattern matching.**

This has mixed results - Claude sometimes still adds redirects despite the instruction.

Environment

  • Claude Code version: 2.0.76
  • OS: Linux 6.18.3-arch1-1 (Arch Linux, x86_64)
  • Node.js: v25.2.1
  • Shell: bash

Reproduction

  1. Add Bash(glab issue view:*) to permissions.allow in settings.json
  2. Run a slash command that triggers glab issue view 123 -R repo 2>/dev/null
  3. Claude prompts for permission despite the pattern matching the command prefix

Expected

Pattern Bash(glab issue view:*) should match glab issue view 123 -R repo 2>/dev/null

Actual

Permission prompt appears, breaking automated workflows.

github-actions[bot] · 8 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 8 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

github-actions[bot] · 8 months 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.