From 457825f77a7c7286647ee888a1000a6bb12ca8fc Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 6 Jun 2021 12:07:11 +0200 Subject: shells: do not allow bare "read" in non-bash compat configs On Sat, Feb 9, 2019 Cristian Ionescu-Idbohrn wrote: > In my case (at work), I have to watch and prevent people from doing > unportable things. For me, that's a burden. Signed-off-by: Denys Vlasenko --- libbb/getopt32.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'libbb/getopt32.c') diff --git a/libbb/getopt32.c b/libbb/getopt32.c index 3785100..5ab4d66 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c @@ -89,6 +89,12 @@ getopt32(char **argv, const char *applet_opts, ...) root:x:0:0:root:/root:/bin/bash user:x:500:500::/home/user:/bin/bash + "^" options string is "^optchars""\0""opt_complementary". + + "!" If the first character in the applet_opts string is a '!', + report bad options, missing required options, + inconsistent options with all-ones return value (instead of abort. + "+" If the first character in the applet_opts string is a plus, then option processing will stop as soon as a non-option is encountered in the argv array. Useful for applets like env @@ -96,10 +102,7 @@ getopt32(char **argv, const char *applet_opts, ...) env -i ls -d / Here we want env to process just the '-i', not the '-d'. - "!" Report bad options, missing required options, - inconsistent options with all-ones return value (instead of abort). - - "^" options string is "^optchars""\0""opt_complementary". + (The order of multiple prefixes must be "^!+...") uint32_t getopt32long(char **argv, const char *applet_opts, const char *logopts...) -- cgit v1.1