From: Pádraig Brady
Date: Tue, 13 Jan 2026 02:01:11 +0000 (+0000) Subject: fmt: correctly diagnose read errors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=495e3528d7c3a9e9e1fc793efecb749b40f130af;p=thirdparty%2Fcoreutils.git fmt: correctly diagnose read errors * src/fmt.c (fmt): Pass errno to error() so that the particular error is diagnosed. * NEWS: Mention the improvement. --- diff --git a/NEWS b/NEWS index b4031caa00..a2facb6361 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,10 @@ GNU coreutils NEWS -*- outline -*- POSIX says this is not portable. [bug introduced in fileutils-4.1.6] + 'fmt' now correctly diagnoses read errors. + Previously fmt generated a generic error for any read error. + [bug introduced in coreutils-9.0] + md5sum --text correctly translates CRLF line endings with the MSYS2 runtime. This also applies to the sha*sum and b2sum utilities. [This bug was present in "the beginning".] diff --git a/src/fmt.c b/src/fmt.c index ae689ec286..8928a32b46 100644 --- a/src/fmt.c +++ b/src/fmt.c @@ -501,9 +501,9 @@ fmt (FILE *f, char const *file) if (0 <= err) { if (f == stdin) - error (0, err, _("read error")); + error (0, errno, _("read error")); else - error (0, err, _("error reading %s"), quoteaf (file)); + error (0, errno, _("error reading %s"), quoteaf (file)); } return err < 0; }