[git commit] tr: display usage for incorrect arguments

Denys Vlasenko vda.linux at googlemail.com
Sun Apr 16 15:54:00 UTC 2023


commit: https://git.busybox.net/busybox/commit/?id=2ffd8986e21f1782c78e1a9d34f6042af53d876c
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

tr must have one or two non-option arguments.  Display the usage
message if any other number is present.

function                                             old     new   delta
.rodata                                           108389  108392      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 3/0)                 Total: 3 bytes

Signed-off-by: Ron Yorston <rmy at pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/tr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/coreutils/tr.c b/coreutils/tr.c
index 1e402dfdb..7fe7f89d5 100644
--- a/coreutils/tr.c
+++ b/coreutils/tr.c
@@ -299,7 +299,7 @@ int tr_main(int argc UNUSED_PARAM, char **argv)
 	 */
 
 	/* '+': stop at first non-option */
-	opts = getopt32(argv, "^+" "Ccds" "\0" "-1");
+	opts = getopt32(argv, "^+" "Ccds" "\0" "-1:?2");
 	argv += optind;
 
 	str1_length = expand(*argv++, &str1);


More information about the busybox-cvs mailing list