Skip to content

fix: bug(rewrite): hook rewrites left-hand side of piped com... - #2229

Closed
gittihub-jpg wants to merge 1 commit into
rtk-ai:developfrom
gittihub-jpg:fix/issue-20260602-1560
Closed

gittihub-jpg wants to merge 1 commit into
rtk-ai:developfrom
gittihub-jpg:fix/issue-20260602-1560

Conversation

@gittihub-jpg

@gittihub-jpg gittihub-jpg commented Jun 2, 2026 •

Copy link
Copy Markdown

Closes #1560

Summary

  • Prevents rtk rewrite from rewriting only the left-hand side of piped commands or subshells.
  • Adds a guard clause in src/hooks/rewrite_cmd.rs to skip rewriting when | or $() is present.
  • Restores expected behavior for downstream filters like grep, tail, and head.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk rewrite 'ps aux | grep python | grep -v grep' output inspected

…-ai#1560)

Fixes rtk-ai#1560

Signed-off-by: gittihub-jpg <rico@springer-mail.net>
@CLAassistant

CLAassistant commented Jun 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gittihub-jpg
gittihub-jpg marked this pull request as ready for review June 2, 2026 21:31
@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 3, 2026
@KuSh

KuSh commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for digging into this. Issue #1560 was fixed on develop by #3128 (merged as ca41893), which stops the rewriter from touching any stage that feeds a pipe and rewrites the final stage only when its filter is safe to read from stdin. I ran the examples from this PR against the current develop binary: git log | head -5, cargo build 2>&1 | tee build.log and every $(...) form pass through untouched, while ls | grep foo becomes ls | rtk grep foo, so the producer is preserved and the useful rewrite is kept. The blanket bypass here would also return exit 0 with the original command, which the hook protocol reads as auto-allow, so piped commands would skip the deny and ask checks. Closing as covered, please comment or reopen if you still see a bad rewrite on the latest develop.

@KuSh KuSh closed this Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(rewrite): hook rewrites left-hand side of piped commands, breaking downstream filters

3 participants