Support byte counts and start-relative selection in native head and tail #14
Labels
No labels
alpha-1
bug
ci
docs
duplicate
enhancement
help wanted
invalid
performance
phase-6
question
refactor
security
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
erix/coreutils#14
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem and motivation
Native head and tail currently select only a line count. Build and diagnostic scripts also need byte prefixes/suffixes and tail output beginning at a particular line or byte.
Proposed behavior and scope
Add -c counts to both commands and +N starting positions to tail -n/-c. Keep the ten-line defaults and share one checked u64 parser between buffered and native execution. Support separate and combined short count options, -- and an explicit stdin operand.
Preserve raw bytes, including NUL, and final unterminated lines. Start positions are one-based; +0 and +1 both select from the beginning. End-relative selection uses caller-owned retention and reports exhausted storage without silently losing data. This scope uses stdin; named-file operands, follow/reopen, count multipliers and negative head counts remain separate work.
Authority, security and reliability
Use only the original stdin/stdout descriptions and existing caller storage. Add no filesystem grants, allocator, service lookup or reopen path. Preserve shared cursor offsets, original callback failures and once-only cleanup. Parse the complete count before I/O; zero end-relative counts require no stream operation.
Acceptance criteria
Alternatives and tradeoffs
An imported utility can supply broader options, but would leave native build scripts dependent on a separate runtime. Streaming start-relative output avoids retaining a suffix; end-relative output still needs enough explicitly supplied storage for the selected data.
Tracking and rollout
Part of Phase 6 completion. Keep broader filename/follow behavior and full in-EriX build acceptance distinct from this stream-selection change.