Bash permission patterns don't match compound commands or commands with redirects
Problem
Bash permission patterns like Bash(ls *), Bash(git *), Bash(gh *) don't reliably match commands when they include:
- Shell operators (
&&,||,;) - Redirects (
2>/dev/null,> file) - Multiline content (e.g.,
--body "..."with newlines)
Examples
These commands prompted for permission despite matching patterns existing:
| Command | Expected Pattern Match | Result |
|---------|----------------------|--------|
| ls -la /path/file 2>/dev/null && echo "EXISTS" \|\| echo "NOT FOUND" | Bash(ls *) | Prompted |
| cd /path && git stash push -m "message" | Bash(cd *) | Prompted |
| gh issue comment 123 --repo org/repo --body "multiline..." | Bash(gh *) | Prompted |
| cat ~/.claude/settings.json | Bash(cat *) | Prompted |
Current Workaround
Adding more specific patterns as duplicates:
"Bash(ls *)",
"Bash(ls -la *)",
"Bash(git *)",
"Bash(git stash *)",
"Bash(gh *)",
"Bash(gh issue comment *)",
"Bash(gh issue close *)",
"Bash(cat *)",
"Bash(cat ~/.claude/*)"
This is verbose and doesn't scale well.
Expected Behavior
Bash(ls *) should match any command that starts with ls , regardless of what follows (redirects, pipes, compound operators).
Environment
- Claude Code version: latest (as of 2026-02-27)
- OS: macOS (Darwin)
- Shell: zsh
Additional Context
The patterns work for simple commands but fail for real-world usage patterns that commonly include error handling (2>/dev/null), chaining (&&), or multiline arguments.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗