From 043d15da31200d35c24bc1939ae6b561f5016c84 Mon Sep 17 00:00:00 2001
From: Denis Vlasenko <vda.linux@googlemail.com>
Date: Mon, 28 Jul 2008 23:49:42 +0000
Subject: tr: fix "tr [=" case. Closes bug 4374.

function                                             old     new   delta
expand                                              1701    1738     +37
tr_main                                              472     474      +2
---
 coreutils/tr.c | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'coreutils')

diff --git a/coreutils/tr.c b/coreutils/tr.c
index 28798fe4f..860b8122b 100644
--- a/coreutils/tr.c
+++ b/coreutils/tr.c
@@ -135,6 +135,8 @@ static unsigned int expand(const char *arg, char *buffer)
 			/* "[xyz...", i=x, arg points to y */
 			if (ENABLE_FEATURE_TR_EQUIV && i == '=') { /* [=CHAR=] */
 				*buffer++ = *arg; /* copy CHAR */
+				if (!*arg || arg[1] != '=' || arg[2] != ']')
+					bb_show_usage();
 				arg += 3;	/* skip CHAR=] */
 				continue;
 			}
-- 
cgit v1.2.3