Support binary strings in native printf #12
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#12
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
Build helpers need binary strings, including the NUL-separated environment
records already written by the bootloader Cargo helper. Native
printfcurrentlyrejects octal escapes and requires the complete result to fit caller workspace.
Proposed behavior and scope
Extend the existing string formatter with
%b, the standard single-byte controlescapes and octal byte escapes. Add
%cfor the first raw operand byte; chooseone NUL for empty or missing character operands without interpreting the rest.
Preserve
%s,%%, format repetition and empty missing string operands. Follow the POSIX string-format contract;document deliberate behavior for unspecified sequences. Support NUL output and
%bcancellation without interpreting operands as commands or format strings.Use one shared formatter for buffered and native execution. Stream large native
results through caller storage; keep one write when the complete result fits.
Numeric conversions, field widths, precision and full locale support stay outside
this change and remain explicitly documented gaps.
Authority, security and reliability
Use only the authenticated original output/error descriptions. This adds no
filesystem, environment, clock, broker or launch authority. Preflight the complete
reachable format and converted operands before output; reject malformed input
without a prefix write. Keep original message and output backing through
unreturned callbacks, preserve first errors and never replay an uncertain write.
Acceptance criteria
escape boundaries, format repetition, empty/missing operands and whole-command
%bcancellation.preserves fitting-result batching and detects malformed input before output.
original stream identity, backing and once-only cleanup.
including a NUL-separated build-style record and subsequent ordinary output.
supported syntax, deliberate errors and explicit stream authority.
Alternatives and tradeoffs
Imported printf implementations remain useful for unsupported numeric formats.
Sharing one allocation-free formatter avoids maintaining different byte rules in
the buffered model and native command. Caller storage controls chunk size rather
than imposing a product output-length limit.
Tracking and rollout
Coordinate Coreutils PR 2,
Integration PR 12 and the
phase checklist.