[BUG] Incorrect escaping for .claude/shell-snapshots/ in zsh with setopt rcquotes
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?
This is related to some existing reports, like #9670 but that is more about capturing too much stuff for the shell snapshot. (My snapshots are ~30k lines, too... that's 757k)
But even more it is related to #1872 because I keep getting the same kind of `.claude/shell-snapshots/snapshot-zsh-1768565670194-de9c7g.sh:15362: parse error near ()'`` issue.
In that issue, someone blamed the zsh plugin. However, by checking the line in the plugin file in my .oh-my-zsh/lib/functions.zsh I see this:
local mark='_.!~*''()-'
Whereas the claude snapshot has:
local mark='_.!~*'()-'
I suspect this is some sort of issue caused by setopt rcquotes (it's a zsh option that makes it possible to do echo 'don''t' and get don't)
What Should Happen?
I would expect if you capture the entire shell environment based on the user's own interactive shell, it should work even if people have some helper options set.
Error Messages/Logs
! echo $CLAUDECODE
⎿ 1
/home/user/.claude/shell-snapshots/snapshot-zsh-1768565670194-de9c7g.sh:15362: parse error near `()'
Steps to Reproduce
- Use zsh
- Install oh-my-zsh
- Add
setopt rcquotesto .zshrc - Run any shell command in claude
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.9 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
For now, I got around it by doing this in my .zshrc
if [[ -z "${CLAUDECODE}" ]]; then
setopt rcquotes
fi
After that, the snapshots seem to have the correct line:
local mark='_.!~*''()-'This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗