Support byte counts and start-relative selection in native head and tail #14

Open
opened 2026-10-26 06:44:42 +01:00 by erikinkinen · 0 comments
Owner

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

  • Implement shared checked count parsing and all declared line/byte selection modes without an incidental count limit.
  • Preserve binary data and exact line boundaries across split reads, partial writes, empty input and genuine retention exhaustion.
  • Preserve original stream ownership, failure packets, aliases and cleanup; add meaningful controls for these paths.
  • Publish coherent command manuals, technical manual and independent guest output/status/hash cases while retaining existing workloads.
  • Complete component and matching-image acceptance for the selected source graph.

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.

## 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 - [ ] Implement shared checked count parsing and all declared line/byte selection modes without an incidental count limit. - [ ] Preserve binary data and exact line boundaries across split reads, partial writes, empty input and genuine retention exhaustion. - [ ] Preserve original stream ownership, failure packets, aliases and cleanup; add meaningful controls for these paths. - [ ] Publish coherent command manuals, technical manual and independent guest output/status/hash cases while retaining existing workloads. - [ ] Complete component and matching-image acceptance for the selected source graph. ## 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](https://git.erikinkinen.fi/erix/integration/issues/65). Keep broader filename/follow behavior and full in-EriX build acceptance distinct from this stream-selection change.
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:33:36 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
erix/coreutils#14
No description provided.