Bash permission pattern with wildcard not matching commands with redirects
Status Closed — not planned
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
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 testnpm run test 2>&1npm 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:*)matchespython 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 -200also doesn't match, which may be expected behavior due to shell operator security (preventingsafe-cmd && malicious-cmdbypasses), but the non-piped redirect case should work
6 Comments
---
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
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.
I'm also running into this issue, but on Linux.
Attempted Workaround
Adding the following to
CLAUDE.md:This has mixed results - Claude sometimes still adds redirects despite the instruction.
Environment
Reproduction
Bash(glab issue view:*)topermissions.allowin settings.jsonglab issue view 123 -R repo 2>/dev/nullExpected
Pattern
Bash(glab issue view:*)should matchglab issue view 123 -R repo 2>/dev/nullActual
Permission prompt appears, breaking automated workflows.
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.
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.
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.