head: continue after per-file read error#12308
Conversation
| loop { | ||
| let n = match reader.read(&mut buf) { | ||
| Ok(0) => break, | ||
| Ok(n) => n, |
There was a problem hiding this comment.
Would you avoid same letter n?
There was a problem hiding this comment.
and avoid one letter variable :)
There was a problem hiding this comment.
A single letter variable is idiomatic for a variable bound by a pattern, but the outer variable should be named something like bytes_read.
|
GNU testsuite comparison: |
Merging this PR will degrade performance by 3.91%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Fixes #11846.
headnow reports per-file read errors correctly and continues processing the remaining input files.Previously, reading from files like
/proc/self/memcould be reported as a standard output write error becauseio::copymixed read and write failures into the same error path.This change keeps read errors associated with the input file, while preserving stdout write error handling.