Shell snapshot captures zero functions when .zshrc defines a function named `grep`
Resolved 💬 3 comments Opened Jan 31, 2026 by pandysp Closed Mar 1, 2026
Summary
Defining a grep() function in .zshrc causes the entire # Functions section of shell snapshots to be empty. All other functions are silently dropped.
Reproduction
# 1. Create .zshrc with grep function
cat > ~/.zshrc << 'ZSHRC'
aaa() { echo "aaa"; }
grep() { echo "guard"; }
ZSHRC
# 2. Delete existing snapshots
rm -rf ~/.claude/shell-snapshots/
# 3. Start claude, run any bash command, then check:
cat ~/.claude/shell-snapshots/snapshot-zsh-*.sh | grep -A5 "^# Functions"
# Result: empty section, aaa() not captured
# 4. Remove grep function, repeat - aaa() is captured
Root cause
Internal shell code uses bare grep:
# Found in binary via: strings ... | grep "grep"
IFS=$'\n' inexact=($(history -n bun | grep -E "^bun add " ...))
A user-defined grep() shadows /usr/bin/grep, breaking snapshot generation.
Suggested fix
Use command grep or /usr/bin/grep in internal shell operations.
Environment
- macOS (Darwin 25.2.0, arm64)
- zsh 5.9
- Claude Code 2.1.27
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗