* NEWS: Mention the improvement.
* src/nl.c (proc_text): Exit if there was an error writing to standard
output.
* tests/misc/write-errors.sh: Enable the test.
---
NEWS | 2 ++
src/nl.c | 3 +++
tests/misc/write-errors.sh | 2 +-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 7641e4f6a..7036bf90f 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,8 @@ GNU coreutils NEWS -*-
outline -*-
'install' now uses posix_spawn() to invoke the strip program more
efficiently.
+ 'nl' will now exit promptly upon receiving a write error.
+
numfmt now parses numbers with a non-breaking space character before a unit,
and parses numbers containing grouping characters from the current locale.
It also supports a multi-byte --delimiter character.
diff --git a/src/nl.c b/src/nl.c
index f243a2953..3a4dfd1de 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -379,6 +379,9 @@ proc_text (void)
}
}
fwrite (line_buf.buffer, sizeof (char), line_buf.length, stdout);
+
+ if (ferror (stdout))
+ write_error ();
}
/* Return the type of line in 'line_buf'. */
diff --git a/tests/misc/write-errors.sh b/tests/misc/write-errors.sh
index b30f4f6bd..ede5b67e7 100755
--- a/tests/misc/write-errors.sh
+++ b/tests/misc/write-errors.sh
@@ -40,7 +40,7 @@ fold -c /dev/zero
fold --version; yes | tr -d '\\n' | fold
head -z -n-1 /dev/zero
join -a 1 -z /dev/zero /dev/null
-# TODO: nl --version; yes | nl
+nl --version; yes | nl
# TODO: numfmt --version; yes 1 | numfmt
od -v /dev/zero
paste /dev/zero
--
2.51.0