Skip to content

fix: skip rewriting find/fd in pipes (#439)#563

Open
pszymkowiak wants to merge 1 commit intodevelopfrom
fix/find-pipe-rewrite
Open

fix: skip rewriting find/fd in pipes (#439)#563
pszymkowiak wants to merge 1 commit intodevelopfrom
fix/find-pipe-rewrite

Conversation

@pszymkowiak
Copy link
Collaborator

Summary

  • Skip rewriting find/fd when followed by a pipe (|)
  • rtk find outputs a grouped format (files space-separated) incompatible with pipe consumers like xargs, grep, wc, sort which expect one path per line
  • find without a pipe is still rewritten to rtk find (savings preserved)

Before

find . -name "*.rs" | xargs grep "fn run"
→ rtk find . -name "*.rs" | xargs grep "fn run"
→ xargs receives "73F 4D: ./ main.rs lib.rs..." → FAILS

After

find . -name "*.rs" | xargs grep "fn run"
→ find . -name "*.rs" | xargs grep "fn run"  (not rewritten)
→ works correctly

Tests

  • test_rewrite_find_pipe_skipped — find with xargs not rewritten
  • test_rewrite_find_pipe_xargs_wc — find with wc not rewritten
  • test_rewrite_find_no_pipe_still_rewritten — find alone still rewritten

Fixes #439

…439)

rtk find outputs a grouped format incompatible with pipe consumers
like xargs, grep, wc, sort. Skip rewrite when find/fd is followed
by a pipe, preserving native one-per-line output.

Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
@pszymkowiak
Copy link
Collaborator Author

Tested manually:

  • rtk rewrite "find src -name *.rs | xargs grep fn" → exit 1 (not rewritten) ✅
  • rtk rewrite "find src -name *.rs"rtk find src -name *.rs (rewritten) ✅
  • /usr/bin/find src -name "*.rs" | /usr/bin/xargs grep -l "fn run" → works correctly with native find ✅
  • 903 tests pass, 3 new tests added

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.

1 participant