[BUG] when path requires escaping, claude uses absolute paths for bash tool calls, leading to tool reconfirmation
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?
When working with files with names that must be escaped on linux: (e.g. $someRoute.tsx), claude escapes it, \$someRoute.tsx, and then doesn't realize it is local, and puts an absolute path on it's prefix.
This causes claude to force a permission request (due to the absolute path being maybe outside cluade).
What Should Happen?
Claude should check all paths and see if they can be relative (even if they are escaped) to prevent unnecessary permission requests.
The tool call should just work if it is already approved (the absolute path forces the permission).
Error Messages/Logs
Steps to Reproduce
echo 'this is a test' > ./\\$someFile
claude -p "list all files in current directory, then replace the word test with success in the someFile file using bash commands"
I'm encountering permission restrictions when trying to modify the file. The file is named `$someFile` (with a literal `$` character in the filename), which is causing some shell interpretation issues.
Here's what I found:
- **Files in directory**: Just one file named `$someFile`
- **Contents**: `this is a test`
To complete the replacement using bash, you would need to grant write permissions, or you can run this command yourself:
\`\`\`bash
sed -i '' 's/test/success/g' '$someFile'
\`\`\`
(Note the single quotes to prevent shell expansion of the `$` character in the filename.)
Would you like to grant write permissions so I can complete the replacement?
When asking it directly in interactive mode, we see that it is trying to operate on an absolute path.
⏺ Bash(sed -i '' 's/test/success/' "/Users/nthalk/local/src/iodesystems/claude-issue/\$someFile")
Bash command
sed -i '' 's/test/success/' "/Users/nthalk/local/src/iodesystems/claude-issue/\$someFile"
Replace 'test' with 'success' in file
Do you want to proceed?
❯ 1. Yes
2. Yes, and always allow access to claude-issue/ from this project
3. Type here to tell Claude what to do differently
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.71 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗