Subject: Re: bug#62497: maybe date -f <directory> should generate an error
From: Paul Eggert <[email-masked]>
To: Sylvestre Ledru <[email-masked]>
Cc: [email-masked]
Date: Tue, 28 Mar 2023 01:54:02 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Thanks for reporting that. I installed the attached to fix it.

From 9c5e542fd190a14431092e3b6cb45d18fe95f26f Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Tue, 28 Mar 2023 01:52:43 -0700
Subject: [PATCH] date: diagnose -f read errors

* src/date.c (batch_convert): Diagnose read errors, fixing Bug#62497.
---
 src/date.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/date.c b/src/date.c
index 0f2012761..bc4cc0ce9 100644
--- a/src/date.c
+++ b/src/date.c
@@ -368,7 +368,9 @@ batch_convert (char const *input_filename, char const *format,
       ssize_t line_length = getline (&line, &buflen, in_stream);
       if (line_length < 0)
         {
-          /* FIXME: detect/handle error here.  */
+          if (ferror (in_stream))
+            die (EXIT_FAILURE, errno, _("%s: read error"),
+                 quotef (input_filename));
           break;
         }
 
-- 
2.37.2