You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
head -n N file has no rewrite rule while tail -n N file does #3667
rewrite_line_range handles four tail spellings but only two head spellings. The
space-separated forms — head -n N file and head --lines N file — fall through unrewritten,
even though tail -n N file and tail --lines N file are both handled.
Command
Rewrite
head -20 f.txt
rtk read f.txt --max-lines 20
head -n 20 f.txt
none
head --lines=20 f.txt
rtk read f.txt --max-lines 20
head --lines 20 f.txt
none
tail -20 f.txt
rtk read f.txt --tail-lines 20
tail -n 20 f.txt
rtk read f.txt --tail-lines 20
tail --lines=20 f.txt
rtk read f.txt --tail-lines 20
tail --lines 20 f.txt
rtk read f.txt --tail-lines 20
Impact
No correctness problem — the command runs natively and returns the right answer. It is lost
savings on one of the most common commands an agent types, and head -n 20 is the more idiomatic
spelling of the two that are handled.
Root cause
static HEAD_N_SPACE and HEAD_LINES_SPACE simply do not exist; the tail arm has its
equivalents.
Already fixed on develop — HEAD_N_SPACE / HEAD_LINES_SPACE were added in #3941 (ed8480f, merged 2026-09-13). Both spellings from the table now rewrite.
Verified against rtk 0.48.0, develop @ b748a5f:
$ cargo test test_rewrite_head
test discover::registry::tests::test_rewrite_head_n_space_flag ... ok
test discover::registry::tests::test_rewrite_head_lines_space_flag ... ok
...
test result: ok. 15 passed; 0 failed
src/discover/registry.rs:96 today, registered in the loop at :1348:
// `-n N` and `--lines N` are the spellings `tail` already accepted below; `head`// silently fell through to no rewrite at all without them.staticHEAD_N_SPACE:LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"^head\s+-n\s+(\d+)\s+(\S+)$").unwrap());staticHEAD_LINES_SPACE:LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"^head\s+--lines\s+(\d+)\s+(\S+)$").unwrap());
The test comment for test_rewrite_head_expanding_operand_stays_native even records it: "Covers the newly added -n N / --lines N routes, which had no matcher at all before and so were native by accident."
All four spellings in the table rewrite now. Suggest closing as completed.
Fixed by #3941, shipped in v0.50.0: head -n N file and head --lines N file now rewrite to rtk read file --head-lines N, the same as the other head and tail spellings. If you still see one of these fall through on the latest version, please comment or reopen.
Activity
pszymkowiak commentedon Aug 23, 2026
🔍 Automated Triage
featurelowSummary
Add rewrite rules for
head -n N fileandhead --lines N file(space-separated forms), matching the coverage already present fortail.📁 Relevant files
src/discover/registry.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
MincongZhou commentedon Sep 23, 2026
Already fixed on
develop—HEAD_N_SPACE/HEAD_LINES_SPACEwere added in #3941 (ed8480f, merged 2026-09-13). Both spellings from the table now rewrite.Verified against rtk 0.48.0,
develop@b748a5f:src/discover/registry.rs:96today, registered in the loop at:1348:The test comment for
test_rewrite_head_expanding_operand_stays_nativeeven records it: "Covers the newly added-n N/--lines Nroutes, which had no matcher at all before and so were native by accident."All four spellings in the table rewrite now. Suggest closing as completed.
KuSh commentedon Sep 26, 2026
Fixed by #3941, shipped in v0.50.0:
head -n N fileandhead --lines N filenow rewrite tortk read file --head-lines N, the same as the other head and tail spellings. If you still see one of these fall through on the latest version, please comment or reopen.