Skip to content

fmt: report unreadable files and go on with the rest - #15923

Merged
cakebaker merged 1 commit into
uutils:mainfrom
emirmrkaljevic:fmt-continue-after-unreadable
Oct 29, 2026
Merged

cakebaker merged 1 commit into
uutils:mainfrom
emirmrkaljevic:fmt-continue-after-unreadable

Conversation

@emirmrkaljevic

Copy link
Copy Markdown
Contributor

Fixes #15922

fmt now reports a file operand it can't open or that is a directory, sets exit status 1, and continues with the remaining files, like GNU. The directory case prints error reading 'dir': Is a directory (GNU's wording) instead of a bare read error; the unused ReadError variant and its fmt-error-read string are replaced by fmt-error-reading-is-directory (en-US and fr-FR).

Found with behave, comparing against GNU coreutils 9.12: fmt d a.txt, fmt missing a.txt, fmt a.txt d, fmt d and fmt d missing now give the same stdout, stderr and exit code as GNU.

Tests: test_fmt_directory, test_fmt_continues_after_directory (both skipped on Windows, where a directory can't be opened as a file) and test_fmt_continues_after_missing_file.

@cakebaker
cakebaker merged commit f064cd5 into uutils:main Oct 29, 2026
139 of 140 checks passed
@cakebaker

Copy link
Copy Markdown
Contributor

Thanks!

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: stops at an unreadable file operand and says only 'read error' for a directory

2 participants