gemini-cli - ✅(Solved) Fix System grep strategy is case-sensitive while git grep and JS fallback are not [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#24955Fetched 2026-04-09 08:16:52
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #24956: fix(core): add case-insensitive flag to system grep strategy

Description (problem / solution / changelog)

Fixes #24955

What

The GrepTool uses three cascading search strategies. The git grep strategy uses --ignore-case and the JS fallback uses RegExp(pattern, 'i'), but the system grep strategy was missing the -i flag — making it case-sensitive on non-git repos where system grep is available.

Fix

Add -i to the system grep args array at line 467, consistent with the other two strategies and with the ripGrep.ts implementation (which already uses --ignore-case).

Tests

  • All 32 grep.test.ts tests pass
  • Lint and prettier pass via pre-commit hooks
  • TypeScript has zero errors on this file

Changed files

  • packages/core/src/tools/grep.ts (modified, +1/-1)

Code Example

const grepArgs = ['-r', '-n', '-H', '-E', '-I'];  // missing -i
RAW_BUFFERClick to expand / collapse

What happened?

The GrepTool has three search strategies that cascade on failure: git grep, system grep, and a JavaScript fallback. Two of these perform case-insensitive matching, but the system grep strategy does not:

StrategyFlagCase-insensitive
git grep--ignore-case (line 418)Yes
system grep(none)No
JS fallbackRegExp(pattern, 'i') (line 553)Yes

This means search results depend on which strategy runs at runtime. On a non-git repo where system grep is available, a search for "TODO" won't match "todo" or "Todo" — but the same search in a git repo (git grep) or on Windows (JS fallback) will match all casings.

The system grep args at packages/core/src/tools/grep.ts line 467:

const grepArgs = ['-r', '-n', '-H', '-E', '-I'];  // missing -i

The exclude_pattern regex on line 404 already uses the 'i' flag, which further confirms case-insensitive was the intended behavior.

What did you expect to happen?

All three strategies should produce consistent case-insensitive results. The system grep strategy should include -i in its argument list, matching the behavior of git grep (--ignore-case) and the JS fallback (RegExp(pattern, 'i')).

Client information

Identified via code review on main branch. Not a runtime reproduction, the inconsistency is visible in the source at packages/core/src/tools/grep.ts line 467 vs line 418 and line 553.

Login information

N/A — code-level bug, not auth-related.

Anything else we need to know?

The ripGrep.ts alternative implementation already uses --ignore-case at line 432, so this inconsistency is specific to the grep.ts system grep path. Submitting a PR shortly.

extent analysis

TL;DR

Add the -i flag to the system grep arguments in grep.ts to enable case-insensitive matching.

Guidance

  • Verify the inconsistency by comparing search results between git grep, system grep, and JS fallback strategies.
  • Update the grepArgs array in packages/core/src/tools/grep.ts line 467 to include the -i flag for case-insensitive matching.
  • Review the ripGrep.ts implementation for consistency, as it already uses --ignore-case at line 432.
  • Test the updated system grep strategy to ensure it produces consistent case-insensitive results with the other two strategies.

Example

const grepArgs = ['-r', '-n', '-H', '-E', '-I', '-i'];  // add -i for case-insensitive matching

Notes

This fix assumes that the system grep implementation supports the -i flag. If the flag is not supported, an alternative approach may be needed.

Recommendation

Apply workaround: Add the -i flag to the system grep arguments to ensure consistent case-insensitive matching across all search strategies.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - ✅(Solved) Fix System grep strategy is case-sensitive while git grep and JS fallback are not [1 pull requests, 1 comments, 2 participants]