]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
fmt: correctly diagnose read errors
authorPádraig Brady <P@draigBrady.com>
Tue, 13 Jan 2026 02:01:11 +0000 (02:01 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 13 Jan 2026 15:08:03 +0000 (15:08 +0000)
* src/fmt.c (fmt): Pass errno to error() so that
the particular error is diagnosed.
* NEWS: Mention the improvement.

NEWS
src/fmt.c

diff --git a/NEWS b/NEWS
index b4031caa009bc612e31aa96d267927d5de8b1122..a2facb6361ac81585b17c2b6d75bf28f0c6f1f97 100644 (file)
--- 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".]
index ae689ec2863c95c811e06872db3e399bce673f09..8928a32b466ead198e85e809ca391a22fc9bb6c3 100644 (file)
--- 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;
 }