[BUG] Bash commands fail with parentheses/brackets in file paths (Next.js route groups)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Bash commands fail when file paths contain shell metacharacters like parentheses () or brackets [].
For example, with a Next.js App Router project using route groups:
- Path:
app/(home)/_components/ - Error:
no matches found: app/(home)/_components/
The shell interprets (home) as a glob pattern or subshell expression instead of a literal directory name.
What Should Happen?
Paths containing special shell characters should be automatically escaped or quoted, similar to how spaces in paths are already handled automatically (as documented: "Path with spaces: Bash commands automatically handle spaces").
Expected: app/(home)/ should work without manual escaping.
Error Messages/Logs
(eval):1: no matches found: /Users/jinsoo/Code/chore/binary01.me-notion-cms/app/(home)/_components/
Steps to Reproduce
- Create a Next.js App Router project with route groups:
mkdir -p "app/(home)/_components"
touch "app/(home)/_components/Page.tsx"
- In Claude Code, run any bash command referencing that path:
- Ask Claude to list files: "list files in app/(home)/_components/"
- Or run a command that involves that directory
- The bash command fails with "no matches found" error
Workaround: Manually quote the path works:
ls 'app/(home)/_components/'ls app/\(home\)/_components/
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.11
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
Affected path patterns (common in modern frameworks):
- Next.js route groups:
app/(home)/,app/(auth)/ - Next.js dynamic routes:
app/[id]/,app/[...slug]/ - Optional catch-all:
app/[[...slug]]/
Related:
The CHANGELOG mentions a similar fix was made before:
"Fixed bash commands failing on Windows when temp directory paths contained characters liketornthat were misinterpreted as escape sequences"
Shell characters that need escaping:
- Parentheses:
()→\(\)or'()' - Brackets:
[]→\[\]or'[]' - And potentially:
$, backticks,&,|,;, etc.
Suggested fix:
Apply shell-safe quoting (like shlex.quote() in Python or equivalent) to file path arguments before passing to bash execution.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗