On 06/01/2026 01:34, Mason Loring Bliss wrote:
On Tue, Jan 06, 2026 at 12:10:48AM +0000, Pádraig Brady wrote:
We should probably use quoted '[:lower:]' and '[:upper:]' in the text
above at least.
For my part, I like that idea.
On Mon, Jan 05, 2026 at 05:16:25PM -0800, Collin Funk wrote:
Not directly related to your issue, but 'tr' doesn't operate on regular
expressions.
Good point. That's worth a rewording.
Agreed. I think it is probably best to leave the explanation of quoting
to the shell's documentation since it affects so much [2].
It still seems like a good idea to mention that this can happen. It's a
way to keep users from being bitten and it's essentially for free by
mentioning that some of the things tr(1) accepts are of interest to various
shells.
Well we have to be careful about exploding the docs,
but a single line is worth it here.
I'll apply the attached later, and I've also added an entry at:
https://www.pixelbeat.org/docs/coreutils-gotchas.html#tr
cheers,
Padraig
From a3ae4123f9481e5e422399b7208970d521a1af12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Tue, 6 Jan 2026 17:24:39 +0000
Subject: [PATCH] doc: tr: warn about shell quoting [:classes:]
* src/tr.c (usage): Warn about avoiding shell globbing.
* doc/coreutils.texi (character arrays): Likewise.
Suggested by Daniel Dallos.
---
doc/coreutils.texi | 3 +++
src/tr.c | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index c42d75753..018dd3af6 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -7074,6 +7074,9 @@ which is of no particular use.
@end table
+Since @samp{[:@var{class}:]} and @samp{[=@var{c}=]} syntax
+are similar to shell globbing syntax, all such class arguments should
+be quoted appropriately, when running @command{tr} from the shell.
@node Translating
@subsection Translating
diff --git a/src/tr.c b/src/tr.c
index 8a184f17a..051274b38 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -342,8 +342,9 @@ Translation occurs if -d is not given and both STRING1 and STRING2 appear.\n\
-t is only significant when translating. ARRAY2 is extended to length of\n\
ARRAY1 by repeating its last character as necessary. Excess characters\n\
of ARRAY2 are ignored. Character classes expand in unspecified order;\n\
-while translating, [:lower:] and [:upper:] may be used in pairs to\n\
+while translating, '[:lower:]' and '[:upper:]' may be used in pairs to\n\
specify case conversion. Squeezing occurs after translation or deletion.\n\
+Arguments like '[...]' should be quoted, to avoid potential shell globbing.\n\
"), stdout);
emit_ancillary_info (PROGRAM_NAME);
}
--
2.52.0