[BUG] Claude CLI fails to escape file paths with spaces in bash commands
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [x] Other: Claude CLI (Claude Code)
- Claude CLI version: 1.0.16 (Claude Code)
- Operating System: macOS 15.5 (24F74)
- Terminal: Visual Studio Code integrated terminal
Bug Description
The Claude CLI fails to properly escape file paths containing spaces when executing bash commands (specifically grep). This causes the command to fail when working with files in directories that have spaces in their names, such as iCloud Drive paths.
Steps to Reproduce
- Ask Claude CLI: "can i delete jobs.html?"
- Claude CLI attempts to search for files using grep
- Grep command fails due to unescaped spaces in file path
Expected Behavior
The file path should be properly quoted/escaped so that grep treats it as a single argument, allowing the command to execute successfully.
Actual Behavior
The grep command fails with "No such file or directory" errors because the unescaped spaces cause the path to be split into multiple arguments:
``grep -n "jobs\.html" /Users/andreas/Library/Mobile\ Documents/com~apple~CloudDocs/Documents/dataproject/index.js``
Results in grep trying to search multiple separate paths instead of the single intended path.
Here is the exact output from Claude cli:
⏺ Bash(grep -n "jobs\.html" /Users/andreas/Library/Mobile\ Documents/com~apple~CloudDocs/Documents/dataproject/index.js)
⎿ Error: grep: /Users/andreas/Library/Mobile\: No such file or directory
grep: Documents/com~apple~CloudDocs/Documents/dataproject/index.js: No such file or directory
Additional Context
This issue specifically affects iCloud Drive paths and other directory structures containing spaces. The path /Users/andreas/Library/Mobile Documents/com~apple~CloudDocs/Documents/dataproject/index.js exists but cannot be accessed due to improper quoting.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗