Skip to content

fix(discover): skip cat -n rewrite for multi-file or wildcard operands - #4979

Open
CG-5228 wants to merge 1 commit into
rtk-ai:developfrom
CG-5228:fix/cat-n-multi-file-rewrite
Open

CG-5228 wants to merge 1 commit into
rtk-ai:developfrom
CG-5228:fix/cat-n-multi-file-rewrite

Conversation

@CG-5228

@CG-5228 CG-5228 commented Nov 3, 2026

Copy link
Copy Markdown

Summary

  • Restrict the cat -n -> rtk read -n rewrite in discover::registry::rewrite_segment_inner to a single concrete file operand (is_single_file_operand), and skip rewriting when trailing flags appear after file operands.
  • Native cat -n a b numbers lines continuously across files, whereas rtk read -n a b restarts numbering at 1 for each file without file headers. Leaving multi-file or wildcard cat -n invocations with native cat preserves line-number correspondence.
  • Add regression tests in src/discover/registry.rs.

Closes #4889

Test Plan

  • cargo test --lib discover::registry::tests::test_rewrite_cat

@CLAassistant

CLAassistant commented Nov 3, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working discover rewrite labels Nov 3, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Restricts the cat -n to rtk read -n rewrite in discover::registry to single concrete file operands, skipping rewriting for multi-file or wildcard invocations since rtk read -n restarts line numbering per file instead of continuing across files like native cat. Adds regression tests to prevent incorrect numbering output.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4889


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working discover rewrite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cat -n a b is rewritten to rtk read -n a b, which restarts the numbering at each file and names no file

2 participants