Bash tool: injected `grep` silently skips .gitignore'd and binary files

Status Open
Reported on v2.1.296
Maintainer reply None cached
Activity 0 comments · opened Oct 13, 2026

Bug Description

  • What happened: In the Bash tool (Claude Code 2.1.296, zsh, macOS), grep is a shell-snapshot function running ugrep with --ignore-files -I. Ignored and binary files are skipped silently: counts are wrong with rc 0, absence checks give a false rc 1.
  • What the user said: User didn't comment; observed by the model.
  • Repro: In a temp dir: echo ignore.txt > .gitignore; echo "MOTIF b" > ignore.txt; grep -r 'MOTIF b' . → rc 1, no output. /usr/bin/grep -r 'MOTIF b' . → ./ignore.txt:MOTIF b, rc 0.
  • Evidence: whence -v grep → shell function from ~/.claude/shell-snapshots/. \grep is also filtered; workaround: /usr/bin/grep or command grep.

Environment Info

  • Platform: darwin
  • Terminal: ghostty
  • Version: 2.1.296
  • Feedback ID: 42b06bcb-7037-45e2-b487-18a24e166a6e

View original on GitHub ↗