Repository navigation
Conversation
`rtk grep pattern` now reads from stdin when output is piped (e.g. `ps aux | rtk grep bash`), matching grep behavior. Also supports `grep -c` via stdin and basic extra_args like `-i`. Fixes: rtk-ai#1476
|
|
📊 Automated PR Analysis
SummaryAdds stdin pipe support to Review Checklist
Linked issues: #1476 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
Thanks for this. Piped stdin for rtk grep landed on develop in #3128 (merged 23 July 2026), which moved grep into src/cmds/system/search.rs and streams piped input instead of searching the filesystem; the -c and -i cases you added are covered there too, and the grep_cmd.rs module this PR edits no longer exists. Verified against a current develop build: piping into rtk grep returns the matching lines, rtk grep -c returns the count, and rtk grep -i matches case-insensitively. Closing as covered, but if some part of your case is still broken please comment here or reopen. |
Summary
rtk grep <pattern>now reads from stdin when input is piped (e.g.ps aux | rtk grep bash), matching plaingrepbehavior.Root cause:
rtk grepalways invokedrg/grepon the filesystem path, ignoring stdin even when the shell had piped data available.Fix: detect non-tty stdin via
std::io::IsTerminal, read and filter lines directly, and output matching results in the same grouped format.Also handles:
grep -cvia stdin (returns bare integer)-icase-insensitive flag via stdinFixes: #1476
Test Plan
cargo test grep_cmd— 9 tests passps aux | rtk grep bashreturns matching linesecho -e "foo\nbar\nfoo" | rtk grep fooreturns 2 matches