[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tr: accept undocumented -u for FreeBSD / macOS compat
|
From: |
Pádraig Brady |
|
Subject: |
[PATCH] tr: accept undocumented -u for FreeBSD / macOS compat |
|
Date: |
Sat, 10 Oct 2026 20:11:12 +0100 |
* src/tr.c (main): Accept -u to set stdout to unbuffered.
* NEWS: Mention the new feature.
Link: https://github.com/coreutils/coreutils/issues/374
---
NEWS | 3 +++
src/tr.c | 7 ++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 2d7d9b3c9..780452af6 100644
--- a/NEWS
+++ b/NEWS
@@ -48,6 +48,9 @@ GNU coreutils NEWS -*-
outline -*-
'env' and 'printenv' now support the --quoting-style option
to control the format of printed environment variables.
+ 'tr' accepts the undocumented -u option to operate in unbuffered mode,
+ for compatibility with FreeBSD and macOS tr(1).
+
** Changes in behavior
'env' and 'printenv' now quote printed environment variables only when
diff --git a/src/tr.c b/src/tr.c
index 7d32257d6..3a1a3b42f 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -1694,7 +1694,7 @@ main (int argc, char **argv)
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "+AcCdst", long_options, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "+AcCdstu", long_options, NULL)) != -1)
{
switch (c)
{
@@ -1721,6 +1721,11 @@ main (int argc, char **argv)
truncate_set1 = true;
break;
+ case 'u':
+ /* Undocumented option, for compatibility with FreeBSD/macOS. */
+ setvbuf (stdout, NULL, _IONBF, 0);
+ break;
+
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
--
2.55.0
- [PATCH] tr: accept undocumented -u for FreeBSD / macOS compat,
Pádraig Brady <=