The 'fold' utility was not very helpful in streaming contexts as
outgoing lines where not sent immediately but whenever the buffer was
full.

Patch attached.

Thanks,
  Henner.
From e83d788dc11688f7739e72578ad440804933218c Mon Sep 17 00:00:00 2001
From: Henner Zeller <[email protected]>
Date: Sun, 5 Jul 2015 11:45:51 -0700
Subject: [PATCH] fold: flush after each line

* src/fold.c: make fold flush after each line to be more useful in
streaming contexts.
---
 src/fold.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/fold.c b/src/fold.c
index 0955c09..4675d47 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -141,6 +141,7 @@ fold_file (char const *filename, size_t width)
     }
 
   fadvise (istream, FADVISE_SEQUENTIAL);
+  setlinebuf (stdout);
 
   while ((c = getc (istream)) != EOF)
     {
-- 
2.4.0

Reply via email to