fix: propagate rg exit code in rtk grep for CLI parity#227
Merged
pszymkowiak merged 1 commit intortk-ai:masterfrom Feb 20, 2026
Merged
Conversation
rtk grep previously returned exit 0 for all failure modes (no match, invalid regex, missing file) where rg returns non-zero. This broke shell workflows relying on exit code semantics. Now propagates rg exit codes: 1 (no match), 2 (error) and surfaces stderr for error cases so users see why the command failed. Fixes rtk-ai#162 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
LGTM — tested locally, all good.
Fixes #162. Ready to merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk grepreturned exit 0 for all failure modes wherergreturns non-zerorgstderr on error so users see why it failedBefore / After
rgnative[)Test plan
rtk grep "zzz" file→ exit 1 (no match)rtk grep "[" file→ exit 2 + stderr error messagertk grep "alpha" /nonexistent→ exit 2 + stderr error messagertk grep "alpha" file→ exit 0 (match found, unchanged)cargo test grep_cmd— 8 tests passcargo test --all— 412 pass, 0 failFixes #162
🤖 Generated with Claude Code