Skip to content

feat(grep): implement missing grep flags (-A/-B/-C, -m, -q, -x, -e)#80

Merged
chaliy merged 3 commits intomainfrom
claude/fix-known-limitations-rHeii
Feb 2, 2026
Merged

feat(grep): implement missing grep flags (-A/-B/-C, -m, -q, -x, -e)#80
chaliy merged 3 commits intomainfrom
claude/fix-known-limitations-rHeii

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 2, 2026

Summary

  • Implements context flags -A, -B, -C for showing lines around matches
  • Implements max count -m N to stop after N matches
  • Implements quiet mode -q for exit status only (no output)
  • Implements whole line match -x for matching entire lines
  • Implements multiple patterns -e pat1 -e pat2 for OR matching

Changes

  • grep.rs: Extended GrepOptions to support new flags, rewrote execute logic for context handling
  • grep.test.sh: Added 15 new test cases covering all new features and edge cases
  • KNOWN_LIMITATIONS.md: Updated grep section to reflect implemented features, updated test counts (55→70 cases)
  • specs/005-builtins.md: Updated grep documentation with new flags

Test plan

  • All grep spec tests pass (70 tests, 56 passing, 14 skipped)
  • All other spec tests pass (bash, awk, sed, jq)
  • Clippy passes with no warnings
  • Formatting check passes
  • Tests cover positive cases (matching, context, multiple patterns)
  • Tests cover negative cases (no match with -m 0, -x partial match)
  • Tests cover edge cases (overlapping context, context at file boundaries)

Implements the following grep features that were listed as missing in
KNOWN_LIMITATIONS.md:

- Context flags: -A (after), -B (before), -C (context)
- Max count flag: -m N (stop after N matches)
- Quiet mode: -q (exit status only, no output)
- Whole line match: -x (match entire line)
- Multiple patterns: -e pat1 -e pat2 (OR matching)

Also adds comprehensive test coverage:
- 15 new test cases for new features
- Tests for edge cases (overlapping context, max count with context)
- Negative tests (no match scenarios)

Updates documentation:
- KNOWN_LIMITATIONS.md: Updated grep section, test counts (55→70 cases)
- specs/005-builtins.md: Added new grep flags to documentation

https://claude.ai/code/session_01C1QHWwiXoRxfaBx6YMLoFa
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@chaliy chaliy merged commit 142b179 into main Feb 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants