[PATCH] tr: display usage for incorrect arguments

Ron Yorston rmy at pobox.com
Sun Apr 16 07:23:58 UTC 2023


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>
---
 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);
-- 
2.39.2



More information about the busybox mailing list