Skip to content

fix(rewrite): handle tail/head -n<N> joined flag form#1180

Closed
1llum1n4t1s wants to merge 1 commit into
rtk-ai:developfrom
1llum1n4t1s:fix/issue-1108-tail-rewrite
Closed

fix(rewrite): handle tail/head -n<N> joined flag form#1180
1llum1n4t1s wants to merge 1 commit into
rtk-ai:developfrom
1llum1n4t1s:fix/issue-1108-tail-rewrite

Conversation

@1llum1n4t1s
Copy link
Copy Markdown

Summary

  • Fix tail -n20 file (no space between -n and number) not being rewritten to rtk read file --tail-lines 20
  • Add missing head -n 20, head -n20, and head --lines 20 rewrite patterns (only head -20 and head --lines=20 were supported)
  • Add 4 new tests covering all new patterns

Root Cause

The TAIL_N_SPACE regex required a mandatory space between -n and the digit (\s+), so tail -n20 fell through unmatched. For head, the -n and --lines <space> forms were never implemented at all.

Test plan

  • cargo test test_rewrite_tail — 7 tests pass
  • cargo test test_rewrite_head — 7 tests pass
  • cargo fmt && cargo clippy --all-targets && cargo test --all — 1357 tests pass, 0 failures
  • End-to-end binary verification of all tail/head flag forms

Closes #1108

🤖 Generated with Claude Code

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 10, 2026

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added bug Something isn't working effort-small Quelques heures, 1 fichier labels Apr 10, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes tail and head command rewrite patterns to handle the joined flag form (e.g., tail -n20 without a space) and adds missing head -n and head --lines <space> rewrite variants. The TAIL_N_SPACE regex is updated to use \s* instead of \s+, and three new regexes are added for head patterns. Four new tests cover all added patterns.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #1108


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

@1llum1n4t1s 1llum1n4t1s changed the base branch from master to develop April 10, 2026 15:14
@1llum1n4t1s 1llum1n4t1s force-pushed the fix/issue-1108-tail-rewrite branch from f76b2ac to f57897a Compare April 10, 2026 15:19
@1llum1n4t1s 1llum1n4t1s force-pushed the fix/issue-1108-tail-rewrite branch from f57897a to 9a36178 Compare May 21, 2026 05:01
The hook rewrite regex missed `tail -n20` and `head -n20` (no space
between -n and the number).  Also adds missing `head -n` and
`head --lines <N>` (space-separated) patterns that were only
implemented for tail.

Closes #1108

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@1llum1n4t1s 1llum1n4t1s force-pushed the fix/issue-1108-tail-rewrite branch from 9a36178 to 0209b08 Compare May 30, 2026 04:40
@1llum1n4t1s
Copy link
Copy Markdown
Author

Closing this PR as it doesn't look like it'll be merged. Feel free to reopen if there's interest. Thanks! 🙏

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

Labels

bug Something isn't working effort-small Quelques heures, 1 fichier

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Code hook: tail -N rewrite produces invalid rtk read -N (should be -n N)

3 participants