tr: fix "tr [=" case. Closes bug 4374.
authorDenis Vlasenko <vda.linux@googlemail.com>
Mon, 28 Jul 2008 23:49:42 +0000 (23:49 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Mon, 28 Jul 2008 23:49:42 +0000 (23:49 -0000)
function                                             old     new   delta
expand                                              1701    1738     +37
tr_main                                              472     474      +2

coreutils/tr.c

index 28798fe4ff5d0c0ddbec58a2d3ffd3fc6b286d8f..860b8122bb7027d3ee5c6bcf961eb25139571ee7 100644 (file)
@@ -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;
                        }