Pádraig Brady <[email protected]> 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

Reply via email to