Skip to content

fmt: propagate read errors instead of silently treating them as EOF#12430

Open
gabrielhnf wants to merge 1 commit into
uutils:mainfrom
gabrielhnf:fix-fmt-error-propagation
Open

fmt: propagate read errors instead of silently treating them as EOF#12430
gabrielhnf wants to merge 1 commit into
uutils:mainfrom
gabrielhnf:fix-fmt-error-propagation

Conversation

@gabrielhnf
Copy link
Copy Markdown
Contributor

@gabrielhnf gabrielhnf commented May 21, 2026

Fixes #10581

FileLines iterator was silently swallowing IO errors by returning None on any read failure, making them indistinguishable from end-of-file. This caused fmt to exit successfully with code 0 when reading files that produce IO errors, such as /proc/self/mem.

Changes:

  • FileLines::Item is now Result<Line, std::io::Error>, propagating read errors to callers
  • Added ParagraphStreamError enum to distinguish between unformatted passthrough lines and IO errors
  • ParagraphStream::Item is now Result<Paragraph, ParagraphStreamError>
  • process_file now returns an error on ParagraphStreamError::IoError instead of iterating over an empty stream
  • Added a regression test that verifies $ fmt /proc/self/mem fails with exit code 1.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/cut/cut-huge-range is now passing!

@gabrielhnf gabrielhnf force-pushed the fix-fmt-error-propagation branch from 3101fed to db48aa6 Compare May 21, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fmt /proc/self/mem silently success

1 participant