claude-code - 💡(How to fix) Fix Bash(echo *) permission pattern does not match commands containing env vars that expand to paths

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

The permission pattern appears to be evaluated against the shell-expanded command value rather than the literal command string. Because $MY_REPO expands to /Users/username/dev/my-repo, the effective check becomes whether echo /Users/username/dev/my-repo matches echo *. Standard glob * does not match /, so the match fails.

Fix Action

Workaround

Add the literal variable reference as an explicit allow entry: "Bash(echo $MY_REPO)". This is fragile and defeats the purpose of wildcard patterns.

RAW_BUFFERClick to expand / collapse

Describe the bug

A Bash(echo *) entry in settings.json permissions.allow does not suppress the permission prompt when the command contains an environment variable that expands to a value with / characters.

Steps to reproduce

  1. Add "Bash(echo *)" to permissions.allow in ~/.claude/settings.json
  2. Have an environment variable set to a path, e.g. MY_REPO=/Users/username/dev/my-repo
  3. Ask Claude to run echo $MY_REPO
  4. Observe: permission prompt appears despite the pattern matching

Expected behavior

Bash(echo *) should match any echo command, including echo $SOME_VAR. The * wildcard should match the literal command string as written, not the shell-expanded result.

Actual behavior

A permission prompt is shown for Bash(echo $MY_REPO).

Hypothesis

The permission pattern appears to be evaluated against the shell-expanded command value rather than the literal command string. Because $MY_REPO expands to /Users/username/dev/my-repo, the effective check becomes whether echo /Users/username/dev/my-repo matches echo *. Standard glob * does not match /, so the match fails.

If correct, any Bash(<cmd> *) pattern will silently fail to match commands whose arguments expand to filesystem paths — a common case for environment variables in developer tooling.

Environment

  • OS: macOS 15.x (Darwin 25.4.0)
  • Claude Code CLI
  • Model: claude-sonnet-4-6

Workaround

Add the literal variable reference as an explicit allow entry: "Bash(echo $MY_REPO)". This is fragile and defeats the purpose of wildcard patterns.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Bash(echo *) should match any echo command, including echo $SOME_VAR. The * wildcard should match the literal command string as written, not the shell-expanded result.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING