Subject: bug#62497: closed (Re: bug#62497: maybe date -f <directory> should generate an error)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 28 Mar 2023 08:55:02 +0000

Your bug report

#62497: maybe date -f <directory> should generate an error

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
62497: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62497
GNU Bug Tracking System
Contact [email-masked] with problems

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

Subject: maybe date -f <directory> should generate an error
From: Sylvestre Ledru <[email-masked]>
To: [email-masked]
Date: Mon, 27 Mar 2023 20:44:40 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello

The usual case is:

$ echo "2023-03-27 08:30:00" > dates.txt
$ echo "2023-04-01 12:00:00" >> dates.txt

$ /usr/bin/date -f dates.txt
Mon Mar 27 08:30:00 CEST 2023
Sat Apr 1 12:00:00 CEST 2023

If done on a non existing file, we get:

$ date -f non-existing
/usr/bin/date: non-existing: No such file or directory

Maybe it should do the same on a directory:

  $ /usr/bin/date -f /
doesn't show anything and return 0

Cheers,
Sylvestre