]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
date: avoid a duplicated write error diagnotic
authorPádraig Brady <P@draigBrady.com>
Mon, 3 Nov 2025 13:00:32 +0000 (13:00 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 3 Nov 2025 13:00:32 +0000 (13:00 +0000)
* src/show-date.c (show_date): Only show the fprintftime() diagnostic
if a further diagnostic will not be shown.

src/show-date.c

index 96cefc8108cdfe6b41a1149fe402a08917ba2037..ff1470e8e047e4c47d5a71ea5def1772c56a6231 100644 (file)
@@ -31,7 +31,8 @@ show_date (char const *format, struct timespec when, timezone_t tz)
 
   if (fprintftime (stdout, format, &tm, tz, when.tv_nsec) < 0)
     {
-      error (0, errno, _("fprintftime error"));
+      if (! ferror (stdout))  /* otherwise it will be diagnosed later.  */
+        error (0, errno, _("fprintftime error"));
       return false;
     }