Write errors coming from the format machinery keep Rust's (os error N) suffix, which GNU does
not print:
$ printf 'foo\n' > /dev/full
printf: write error: No space left on device (os error 28)
$ /usr/bin/printf 'foo\n' > /dev/full
printf: write error: No space left on device
Both exit 1, so only the message differs.
Where
src/uucore/src/lib/features/format/mod.rs:116
Self::IoError(e) => write!(f, "write error: {e}"),
uucore::error::strip_errno exists for exactly this and is already used elsewhere, e.g.
src/uucore/src/lib/features/perms.rs and src/uucore/src/lib/features/checksum/mod.rs, both of
which format the same message as "{}: {}", translate!("common-write-error"), strip_errno(..).
Note on reproducing
The trailing newline matters: it makes the line-buffered stdout flush inside the format code,
which is the path that produces this message. printf 'foo' > /dev/full (no newline) fails
later, on the flush at exit, and takes a different code path with a correct message.
Why this is a good first issue
One-line change plus a regression test in tests/by-util/test_printf.rs, and it makes the output
match GNU exactly. Worth a quick grep for other spots that interpolate an io::Error directly
into a user-facing message.
Found with coreutils 0.10.0 (multi-call binary) at 282b8b4, compared against GNU coreutils
9.11.64.
Write errors coming from the format machinery keep Rust's
(os error N)suffix, which GNU doesnot print:
Both exit 1, so only the message differs.
Where
src/uucore/src/lib/features/format/mod.rs:116uucore::error::strip_errnoexists for exactly this and is already used elsewhere, e.g.src/uucore/src/lib/features/perms.rsandsrc/uucore/src/lib/features/checksum/mod.rs, both ofwhich format the same message as
"{}: {}", translate!("common-write-error"), strip_errno(..).Note on reproducing
The trailing newline matters: it makes the line-buffered stdout flush inside the format code,
which is the path that produces this message.
printf 'foo' > /dev/full(no newline) failslater, on the flush at exit, and takes a different code path with a correct message.
Why this is a good first issue
One-line change plus a regression test in
tests/by-util/test_printf.rs, and it makes the outputmatch GNU exactly. Worth a quick
grepfor other spots that interpolate anio::Errordirectlyinto a user-facing message.
Found with
coreutils 0.10.0(multi-call binary) at 282b8b4, compared against GNU coreutils9.11.64.