coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ls: promptly diagnose write errors


From: Pádraig Brady
Subject: Re: [PATCH] ls: promptly diagnose write errors
Date: Sun, 11 Jan 2026 19:51:41 +0000
User-agent: Mozilla Thunderbird Beta

On 11/01/2026 19:32, Collin Funk wrote:
Pádraig Brady <P@draigBrady.com> writes:

On 11/01/2026 07:17, Collin Funk wrote:
There are two things about this patch that I am unsure about.
When we receive a write error, should we attempt to restore the
default terminal colors? The write to standard output will almost
certainly not work, but is it worth a shot anyways?
Second, I am not really sure of a test case to add for this. Doing
'ls -R $HOME' or 'ls -R /' should take long enough, but I would rather
not access anything outside of the checkout or $TMPDIR in the test suite.
Any ideas?

I'm 50:50 on this one because:

* The question about terminal reset
* 3 call sites (albeit minimal overhead)
* impractical usage (evidenced by awkward testing)

We can reduce it to one call per directory. That would help in the
recursive case, but not the case of many entries in a single directory
(which is pretty fast anyways).

diff --git a/src/ls.c b/src/ls.c
index b349c74dc..b2e6780da 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4101,6 +4101,9 @@ print_current_files (void)
          }
        break;
      }
+
+  if (ferror (stdout))
+    write_error ();
  }
/* Replace the first %b with precomputed aligned month names.

Collin

OK I've adjusted my thoughts to 60:40 for the original patch.

cheers,
Padraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]