aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archival/tar.c15
-rw-r--r--coreutils/du.c8
-rw-r--r--coreutils/env.c3
-rw-r--r--coreutils/od_bloaty.c3
-rw-r--r--coreutils/sort.c5
-rw-r--r--coreutils/split.c4
-rw-r--r--coreutils/tail.c4
-rw-r--r--coreutils/uniq.c3
-rw-r--r--debianutils/run_parts.c4
-rw-r--r--editors/awk.c8
-rw-r--r--editors/diff.c4
-rw-r--r--editors/sed.c5
-rw-r--r--findutils/grep.c8
-rw-r--r--init/halt.c3
-rw-r--r--libbb/getopt32.c82
-rw-r--r--libbb/parse_config.c4
-rw-r--r--loginutils/cryptpw.c4
-rw-r--r--loginutils/getty.c4
-rw-r--r--loginutils/sulogin.c3
-rw-r--r--mailutils/makemime.c3
-rw-r--r--mailutils/popmaildir.c4
-rw-r--r--mailutils/reformime.c4
-rw-r--r--mailutils/sendmail.c4
-rw-r--r--miscutils/conspy.c4
-rw-r--r--miscutils/ionice.c3
-rw-r--r--miscutils/microcom.c3
-rw-r--r--miscutils/timeout.c3
-rw-r--r--miscutils/ubi_tools.c8
-rw-r--r--networking/arping.c4
-rw-r--r--networking/ftpd.c6
-rw-r--r--networking/ifplugd.c5
-rw-r--r--networking/inetd.c4
-rw-r--r--networking/nc_bloaty.c4
-rw-r--r--networking/ntpd.c4
-rw-r--r--networking/ping.c4
-rw-r--r--networking/tcpudp.c4
-rw-r--r--networking/telnetd.c4
-rw-r--r--networking/traceroute.c4
-rw-r--r--networking/udhcp/d6_dhcpc.c4
-rw-r--r--networking/udhcp/dhcpc.c4
-rw-r--r--networking/wget.c3
-rw-r--r--networking/whois.c4
-rw-r--r--procps/pgrep.c3
-rw-r--r--procps/pidof.c3
-rw-r--r--procps/ps.c3
-rw-r--r--procps/watch.c4
-rw-r--r--runit/chpst.c4
-rw-r--r--runit/sv.c4
-rw-r--r--selinux/setfiles.c6
-rw-r--r--sysklogd/syslogd.c6
-rw-r--r--util-linux/dmesg.c3
-rw-r--r--util-linux/fdisk.c3
-rw-r--r--util-linux/getopt.c3
-rw-r--r--util-linux/mkfs_ext2.c3
-rw-r--r--util-linux/mkfs_minix.c3
-rw-r--r--util-linux/mkfs_reiser.c4
-rw-r--r--util-linux/mount.c4
-rw-r--r--util-linux/readprofile.c3
58 files changed, 168 insertions, 159 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 7434e22e4..8e315c610 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -980,7 +980,6 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
/* Prepend '-' to the first argument if required */
opt_complementary = "--:" // first arg is options
"tt:vv:" // count -t,-v
- IF_FEATURE_TAR_FROM("X::T::") // cumulative lists
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
"\xff::" // --exclude=PATTERN is a list
#endif
@@ -1032,13 +1031,13 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
#endif
opt = getopt32(argv,
"txC:f:Oopvk"
- IF_FEATURE_TAR_CREATE( "ch" )
- IF_FEATURE_SEAMLESS_BZ2( "j" )
- IF_FEATURE_SEAMLESS_LZMA("a" )
- IF_FEATURE_TAR_FROM( "T:X:")
- IF_FEATURE_SEAMLESS_GZ( "z" )
- IF_FEATURE_SEAMLESS_XZ( "J" )
- IF_FEATURE_SEAMLESS_Z( "Z" )
+ IF_FEATURE_TAR_CREATE( "ch" )
+ IF_FEATURE_SEAMLESS_BZ2( "j" )
+ IF_FEATURE_SEAMLESS_LZMA("a" )
+ IF_FEATURE_TAR_FROM( "T:*X:*")
+ IF_FEATURE_SEAMLESS_GZ( "z" )
+ IF_FEATURE_SEAMLESS_XZ( "J" )
+ IF_FEATURE_SEAMLESS_Z( "Z" )
IF_FEATURE_TAR_NOPRESERVE_TIME("m")
IF_FEATURE_TAR_LONG_OPTIONS("\xf9:") // --strip-components
, &base_dir // -C dir
diff --git a/coreutils/du.c b/coreutils/du.c
index 1240bcbbc..5f104736b 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -226,8 +226,8 @@ int du_main(int argc UNUSED_PARAM, char **argv)
* ignore -a. This is consistent with -s being equivalent to -d 0.
*/
#if ENABLE_FEATURE_HUMAN_READABLE
- opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+";
- opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth);
+ opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
+ opt = getopt32(argv, "aHkLsx" "d:+" "lc" "hm", &G.max_print_depth);
argv += optind;
if (opt & OPT_h_for_humans) {
G.disp_unit = 0;
@@ -239,8 +239,8 @@ int du_main(int argc UNUSED_PARAM, char **argv)
G.disp_unit = 1024;
}
#else
- opt_complementary = "H-L:L-H:s-d:d-s:d+";
- opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth);
+ opt_complementary = "H-L:L-H:s-d:d-s";
+ opt = getopt32(argv, "aHkLsx" "d:+" "lc", &G.max_print_depth);
argv += optind;
#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
if (opt & OPT_k_kbytes) {
diff --git a/coreutils/env.c b/coreutils/env.c
index 807ef13e9..cdfc30e14 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -54,11 +54,10 @@ int env_main(int argc UNUSED_PARAM, char **argv)
unsigned opts;
llist_t *unset_env = NULL;
- opt_complementary = "u::";
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
applet_long_options = env_longopts;
#endif
- opts = getopt32(argv, "+iu:", &unset_env);
+ opts = getopt32(argv, "+iu:+", &unset_env);
argv += optind;
if (argv[0] && LONE_DASH(argv[0])) {
opts |= 1;
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index c8a654165..f13bdfc11 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -62,7 +62,7 @@ enum {
};
#define OD_GETOPT32() getopt32(argv, \
- "A:N:abcdfhij:lot:vxsS:w::", \
+ "A:N:abcdfhij:lot:*vxsS:w:+:", \
/* -w with optional param */ \
/* -S was -s and also had optional parameter */ \
/* but in coreutils 6.3 it was renamed and now has */ \
@@ -1212,7 +1212,6 @@ int od_main(int argc UNUSED_PARAM, char **argv)
address_pad_len_char = '7';
/* Parse command line */
- opt_complementary = "w+:t::"; /* -w N, -t is a list */
#if ENABLE_LONG_OPTS
applet_long_options = od_longopts;
#endif
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 9139d9f47..34a41999b 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -73,7 +73,7 @@
*/
/* These are sort types */
-static const char OPT_STR[] ALIGN1 = "ngMucszbrdfimS:T:o:k:t:";
+static const char OPT_STR[] ALIGN1 = "ngMucszbrdfimS:T:o:k:*t:";
enum {
FLAG_n = 1, /* Numeric sort */
FLAG_g = 2, /* Sort using strtod() */
@@ -358,8 +358,7 @@ int sort_main(int argc UNUSED_PARAM, char **argv)
/* Parse command line options */
/* -o and -t can be given at most once */
- opt_complementary = "o--o:t--t:" /* -t, -o: at most one of each */
- "k::"; /* -k takes list */
+ opt_complementary = "o--o:t--t"; /* -t, -o: at most one of each */
opts = getopt32(argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t);
/* global b strips leading and trailing spaces */
if (opts & FLAG_b)
diff --git a/coreutils/split.c b/coreutils/split.c
index e67c3de66..19d58a21b 100644
--- a/coreutils/split.c
+++ b/coreutils/split.c
@@ -81,8 +81,8 @@ int split_main(int argc UNUSED_PARAM, char **argv)
setup_common_bufsiz();
- opt_complementary = "?2:a+"; /* max 2 args; -a N */
- opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len);
+ opt_complementary = "?2"; /* max 2 args; -a N */
+ opt = getopt32(argv, "l:b:a:+", &count_p, &count_p, &suffix_len);
if (opt & SPLIT_OPT_l)
cnt = XATOOFF(count_p);
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 39f87679e..57ad0f3b7 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -121,8 +121,8 @@ int tail_main(int argc, char **argv)
#endif
/* -s NUM, -F imlies -f */
- IF_FEATURE_FANCY_TAIL(opt_complementary = "s+:Ff";)
- opt = getopt32(argv, "fc:n:" IF_FEATURE_FANCY_TAIL("qs:vF"),
+ IF_FEATURE_FANCY_TAIL(opt_complementary = "Ff";)
+ opt = getopt32(argv, "fc:n:" IF_FEATURE_FANCY_TAIL("qs:+vF"),
&str_c, &str_n IF_FEATURE_FANCY_TAIL(,&sleep_period));
#define FOLLOW (opt & 0x1)
#define COUNT_BYTES (opt & 0x2)
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index e0133998a..ec7bde418 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -50,8 +50,7 @@ int uniq_main(int argc UNUSED_PARAM, char **argv)
skip_fields = skip_chars = 0;
max_chars = INT_MAX;
- opt_complementary = "f+:s+:w+";
- opt = getopt32(argv, "cduf:s:w:", &skip_fields, &skip_chars, &max_chars);
+ opt = getopt32(argv, "cduf:+s:+w:+", &skip_fields, &skip_chars, &max_chars);
argv += optind;
input_filename = argv[0];
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index c671b9252..0bb666abc 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -181,8 +181,8 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
applet_long_options = runparts_longopts;
#endif
/* We require exactly one argument: the directory name */
- opt_complementary = "=1:a::";
- getopt32(argv, "a:u:", &arg_list, &umask_p);
+ opt_complementary = "=1";
+ getopt32(argv, "a:*u:", &arg_list, &umask_p);
umask(xstrtou_range(umask_p, 8, 0, 07777));
diff --git a/editors/awk.c b/editors/awk.c
index 69816464d..d0269b9f4 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -72,12 +72,9 @@
#define OPTSTR_AWK \
- "F:v:f:" \
- IF_FEATURE_AWK_GNU_EXTENSIONS("e:") \
+ "F:v:*f:*" \
+ IF_FEATURE_AWK_GNU_EXTENSIONS("e:*") \
"W:"
-#define OPTCOMPLSTR_AWK \
- "v::f::" \
- IF_FEATURE_AWK_GNU_EXTENSIONS("e::")
enum {
OPTBIT_F, /* define field separator */
OPTBIT_v, /* define variable */
@@ -3209,7 +3206,6 @@ int awk_main(int argc, char **argv)
*s1 = '=';
}
}
- opt_complementary = OPTCOMPLSTR_AWK;
opt = getopt32(argv, OPTSTR_AWK, &opt_F, &list_v, &list_f, IF_FEATURE_AWK_GNU_EXTENSIONS(&list_e,) NULL);
argv += optind;
argc -= optind;
diff --git a/editors/diff.c b/editors/diff.c
index ff269360f..75229ad8c 100644
--- a/editors/diff.c
+++ b/editors/diff.c
@@ -982,11 +982,11 @@ int diff_main(int argc UNUSED_PARAM, char **argv)
INIT_G();
/* exactly 2 params; collect multiple -L <label>; -U N */
- opt_complementary = "=2:L::U+";
+ opt_complementary = "=2";
#if ENABLE_FEATURE_DIFF_LONG_OPTIONS
applet_long_options = diff_longopts;
#endif
- getopt32(argv, "abdiL:NqrsS:tTU:wupBE",
+ getopt32(argv, "abdiL:*NqrsS:tTU:+wupBE",
&L_arg, &s_start, &opt_U_context);
argv += optind;
while (L_arg)
diff --git a/editors/sed.c b/editors/sed.c
index f37c37d88..c0d79cc7b 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -1503,8 +1503,7 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
/* do normal option parsing */
opt_e = opt_f = NULL;
opt_i = NULL;
- opt_complementary = "e::f::" /* can occur multiple times */
- "nn"; /* count -n */
+ opt_complementary = "nn"; /* count -n */
IF_LONG_OPTS(applet_long_options = sed_longopts);
@@ -1513,7 +1512,7 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
* GNU sed 4.2.1 mentions it in neither --help
* nor manpage, but does recognize it.
*/
- opt = getopt32(argv, "i::rEne:f:", &opt_i, &opt_e, &opt_f,
+ opt = getopt32(argv, "i::rEne:*f:*", &opt_i, &opt_e, &opt_f,
&G.be_quiet); /* counter for -n */
//argc -= optind;
argv += optind;
diff --git a/findutils/grep.c b/findutils/grep.c
index aeb7977e9..7e0120ba2 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -115,8 +115,8 @@
//usage:#define fgrep_full_usage ""
#define OPTSTR_GREP \
- "lnqvscFiHhe:f:Lorm:wx" \
- IF_FEATURE_GREP_CONTEXT("A:B:C:") \
+ "lnqvscFiHhe:*f:*Lorm:+wx" \
+ IF_FEATURE_GREP_CONTEXT("A:+B:+C:+") \
IF_FEATURE_GREP_EGREP_ALIAS("E") \
IF_EXTRA_COMPAT("z") \
"aI"
@@ -695,7 +695,7 @@ int grep_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_GREP_CONTEXT
/* -H unsets -h; -C unsets -A,-B; -e,-f are lists;
* -m,-A,-B,-C have numeric param */
- opt_complementary = "H-h:C-AB:e::f::m+:A+:B+:C+";
+ opt_complementary = "H-h:C-AB";
opts = getopt32(argv,
OPTSTR_GREP,
&pattern_head, &fopt, &max_matches,
@@ -724,7 +724,7 @@ int grep_main(int argc UNUSED_PARAM, char **argv)
#else
/* with auto sanity checks */
/* -H unsets -h; -c,-q or -l unset -n; -e,-f are lists; -m N */
- opt_complementary = "H-h:c-n:q-n:l-n:e::f::m+";
+ opt_complementary = "H-h:c-n:q-n:l-n:";
getopt32(argv, OPTSTR_GREP,
&pattern_head, &fopt, &max_matches);
#endif
diff --git a/init/halt.c b/init/halt.c
index 572d751b0..29e60657b 100644
--- a/init/halt.c
+++ b/init/halt.c
@@ -113,12 +113,11 @@ int halt_main(int argc UNUSED_PARAM, char **argv)
continue;
/* Parse and handle arguments */
- opt_complementary = "d+"; /* -d N */
/* We support -w even if !ENABLE_FEATURE_WTMP,
* in order to not break scripts.
* -i (shut down network interfaces) is ignored.
*/
- flags = getopt32(argv, "d:nfwi", &delay);
+ flags = getopt32(argv, "d:+nfwi", &delay);
sleep(delay);
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index d0e83d88e..15b6efc09 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -17,23 +17,20 @@
uint32_t
getopt32(char **argv, const char *applet_opts, ...)
- The command line options must be declared in const char
- *applet_opts as a string of chars, for example:
-
- flags = getopt32(argv, "rnug");
+ The command line options are passed as the applet_opts string.
If one of the given options is found, a flag value is added to
- the return value (an unsigned long).
+ the return value.
The flag value is determined by the position of the char in
- applet_opts string. For example, in the above case:
+ applet_opts string. For example:
flags = getopt32(argv, "rnug");
- "r" will add 1 (bit 0)
- "n" will add 2 (bit 1)
- "u" will add 4 (bit 2)
- "g" will add 8 (bit 3)
+ "r" will set 1 (bit 0)
+ "n" will set 2 (bit 1)
+ "u" will set 4 (bit 2)
+ "g" will set 8 (bit 3)
and so on. You can also look at the return value as a bit
field and each option sets one bit.
@@ -45,7 +42,7 @@ getopt32(char **argv, const char *applet_opts, ...)
(options and their parameters will be moved into argv[]
positions prior to argv[optind]).
- ":" If one of the options requires an argument, then add a ":"
+ "o:" If one of the options requires an argument, then add a ":"
after the char in applet_opts and provide a pointer to store
the argument. For example:
@@ -58,15 +55,39 @@ getopt32(char **argv, const char *applet_opts, ...)
&pointer_to_arg_for_a, &pointer_to_arg_for_b,
&pointer_to_arg_for_c, &pointer_to_arg_for_d);
- The type of the pointer (char* or llist_t*) may be controlled
- by the "::" special separator that is set in the external string
- opt_complementary (see below for more info).
+ The type of the pointer may be controlled by "o::" or "o+" in
+ the external string opt_complementary (see below for more info).
- "::" If option can have an *optional* argument, then add a "::"
+ "o::" If option can have an *optional* argument, then add a "::"
after its char in applet_opts and provide a pointer to store
the argument. Note that optional arguments _must_
immediately follow the option: -oparam, not -o param.
+ "o:+" This means that the parameter for this option is a nonnegative integer.
+ It will be processed with xatoi_positive() - allowed range
+ is 0..INT_MAX.
+
+ int param; // "unsigned param;" will also work
+ getopt32(argv, "p:+", &param);
+
+ "o:*" This means that the option can occur multiple times. Each occurrence
+ will be saved as a llist_t element instead of char*.
+
+ For example:
+ The grep applet can have one or more "-e pattern" arguments.
+ In this case you should use getopt32() as follows:
+
+ llist_t *patterns = NULL;
+
+ (this pointer must be initializated to NULL if the list is empty
+ as required by llist_add_to_end(llist_t **old_head, char *new_item).)
+
+ getopt32(argv, "e:*", &patterns);
+
+ $ grep -e user -e root /etc/passwd
+ root:x:0:0:root:/root:/bin/bash
+ user:x:500:500::/home/user:/bin/bash
+
"+" 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
@@ -82,7 +103,7 @@ const char *applet_long_options
This struct allows you to define long options:
static const char applet_longopts[] ALIGN1 =
- //"name\0" has_arg val
+ //"name\0" has_arg val
"verbose\0" No_argument "v"
;
applet_long_options = applet_longopts;
@@ -90,7 +111,7 @@ const char *applet_long_options
The last member of struct option (val) typically is set to
matching short option from applet_opts. If there is no matching
char in applet_opts, then:
- - return bit have next position after short options
+ - return bit has next position after short options
- if has_arg is not "No_argument", use ptr for arg also
- opt_complementary affects it too
@@ -139,8 +160,8 @@ const char *opt_complementary
llist_t *my_b = NULL;
int verbose_level = 0;
- opt_complementary = "vv:b::b-c:c-b";
- f = getopt32(argv, "vb:c", &my_b, &verbose_level);
+ opt_complementary = "vv:b-c:c-b";
+ f = getopt32(argv, "vb:*c", &my_b, &verbose_level);
if (f & 2) // -c after -b unsets -b flag
while (my_b) dosomething_with(llist_pop(&my_b));
if (my_b) // but llist is stored if -b is specified
@@ -233,7 +254,7 @@ Special characters:
"x--x" Variation of the above, it means that -x option should occur
at most once.
- "a+" A plus after a char in opt_complementary means that the parameter
+ "o+" A plus after a char in opt_complementary means that the parameter
for this option is a nonnegative integer. It will be processed
with xatoi_positive() - allowed range is 0..INT_MAX.
@@ -241,7 +262,7 @@ Special characters:
opt_complementary = "p+";
getopt32(argv, "p:", &param);
- "a::" A double colon after a char in opt_complementary means that the
+ "o::" A double colon after a char in opt_complementary means that the
option can occur multiple times. Each occurrence will be saved as
a llist_t element instead of char*.
@@ -255,12 +276,17 @@ Special characters:
as required by llist_add_to_end(llist_t **old_head, char *new_item).)
opt_complementary = "e::";
-
getopt32(argv, "e:", &patterns);
+
$ grep -e user -e root /etc/passwd
root:x:0:0:root:/root:/bin/bash
user:x:500:500::/home/user:/bin/bash
+ "o+" and "o::" can be handled by "o:+" and "o:*" specifiers
+ in option string (and it is preferred), but this does not work
+ for "long options only" cases, such as tar --exclude=PATTERN,
+ wget --header=HDR cases.
+
"a?b" A "?" between an option and a group of options means that
at least one of them is required to occur if the first option
occurs in preceding command line arguments.
@@ -359,10 +385,11 @@ getopt32(char **argv, const char *applet_opts, ...)
va_start(p, applet_opts);
- c = 0;
on_off = complementary;
memset(on_off, 0, sizeof(complementary));
+ applet_opts = strcpy(alloca(strlen(applet_opts) + 1), applet_opts);
+
/* skip bbox extension */
first_char = applet_opts[0];
if (first_char == '!')
@@ -372,6 +399,7 @@ getopt32(char **argv, const char *applet_opts, ...)
s = (const unsigned char *)applet_opts;
if (*s == '+' || *s == '-')
s++;
+ c = 0;
while (*s) {
if (c >= 32)
break;
@@ -379,6 +407,13 @@ getopt32(char **argv, const char *applet_opts, ...)
on_off->switch_on = (1 << c);
if (*++s == ':') {
on_off->optarg = va_arg(p, void **);
+ if (s[1] == '+' || s[1] == '*') {
+ /* 'o:+' or 'o:*' */
+ on_off->param_type = (s[1] == '+') ?
+ PARAM_INT : PARAM_LIST;
+ overlapping_strcpy((char*)s + 1, (char*)s + 2);
+ }
+ /* skip possible 'o::' (or 'o:+:' !) */
while (*++s == ':')
continue;
}
@@ -431,6 +466,7 @@ getopt32(char **argv, const char *applet_opts, ...)
applet_long_options = NULL;
}
#endif /* ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG */
+
for (s = (const unsigned char *)opt_complementary; s && *s; s++) {
t_complementary *pair;
unsigned *pair_switch;
diff --git a/libbb/parse_config.c b/libbb/parse_config.c
index 1590d9a4c..408439766 100644
--- a/libbb/parse_config.c
+++ b/libbb/parse_config.c
@@ -42,8 +42,8 @@ int parse_main(int argc UNUSED_PARAM, char **argv)
int mintokens = 0, ntokens = 128;
unsigned noout;
- opt_complementary = "-1:n+:m+:f+";
- noout = 1 & getopt32(argv, "xn:m:d:f:", &ntokens, &mintokens, &delims, &flags);
+ opt_complementary = "-1";
+ noout = 1 & getopt32(argv, "xn:+m:+d:f:+", &ntokens, &mintokens, &delims, &flags);
//argc -= optind;
argv += optind;
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c
index 23a1884f4..9f5f40686 100644
--- a/loginutils/cryptpw.c
+++ b/loginutils/cryptpw.c
@@ -111,8 +111,8 @@ int cryptpw_main(int argc UNUSED_PARAM, char **argv)
opt_m = CONFIG_FEATURE_DEFAULT_PASSWD_ALGO;
opt_S = NULL;
/* at most two non-option arguments; -P NUM */
- opt_complementary = "?2:P+";
- getopt32(argv, "sP:S:m:a:", &fd, &opt_S, &opt_m, &opt_m);
+ opt_complementary = "?2";
+ getopt32(argv, "sP:+S:m:a:", &fd, &opt_S, &opt_m, &opt_m);
argv += optind;
/* have no idea how to handle -s... */
diff --git a/loginutils/getty.c b/loginutils/getty.c
index b10bdbdbf..162c1697e 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -131,7 +131,7 @@ struct globals {
//usage: "\n"
//usage: "\nBAUD_RATE of 0 leaves it unchanged"
-static const char opt_string[] ALIGN1 = "I:LH:f:hil:mt:wn";
+static const char opt_string[] ALIGN1 = "I:LH:f:hil:mt:+wn";
#define F_INITSTRING (1 << 0) /* -I */
#define F_LOCAL (1 << 1) /* -L */
#define F_FAKEHOST (1 << 2) /* -H */
@@ -179,7 +179,7 @@ static void parse_args(char **argv)
char *ts;
int flags;
- opt_complementary = "-2:t+"; /* at least 2 args; -t N */
+ opt_complementary = "-2"; /* at least 2 args; -t N */
flags = getopt32(argv, opt_string,
&G.initstring, &G.fakehost, &G.issue,
&G.login, &G.timeout
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index f32469551..6befea933 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -43,8 +43,7 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
logmode = LOGMODE_BOTH;
openlog(applet_name, 0, LOG_AUTH);
- opt_complementary = "t+"; /* -t N */
- getopt32(argv, "t:", &timeout);
+ getopt32(argv, "t:+", &timeout);
argv += optind;
if (argv[0]) {
diff --git a/mailutils/makemime.c b/mailutils/makemime.c
index 1dadd715f..8e1bc664c 100644
--- a/mailutils/makemime.c
+++ b/mailutils/makemime.c
@@ -184,9 +184,8 @@ int makemime_main(int argc UNUSED_PARAM, char **argv)
INIT_G();
// parse options
- opt_complementary = "a::";
opts = getopt32(argv,
- "c:e:o:C:N:a:", // "m:j:",
+ "c:e:o:C:N:a:*", // "m:j:",
&content_type, NULL, &opt_output, &G.opt_charset, NULL, &opt_headers //, NULL, NULL
);
//argc -= optind;
diff --git a/mailutils/popmaildir.c b/mailutils/popmaildir.c
index 62030331e..69eca6164 100644
--- a/mailutils/popmaildir.c
+++ b/mailutils/popmaildir.c
@@ -107,9 +107,9 @@ int popmaildir_main(int argc UNUSED_PARAM, char **argv)
INIT_G();
// parse options
- opt_complementary = "-1:dd:t+:R+:L+:H+";
+ opt_complementary = "-1:dd";
opts = getopt32(argv,
- "bdmVcasTkt:" "R:Z:L:H:" IF_FEATURE_POPMAILDIR_DELIVERY("M:F:"),
+ "bdmVcasTkt:+" "R:+Z:L:+H:+" IF_FEATURE_POPMAILDIR_DELIVERY("M:F:"),
&timeout, NULL, NULL, NULL, &opt_nlines
IF_FEATURE_POPMAILDIR_DELIVERY(, &delivery, &delivery) // we treat -M and -F the same
);
diff --git a/mailutils/reformime.c b/mailutils/reformime.c
index 86b2cfed3..b967dfbc7 100644
--- a/mailutils/reformime.c
+++ b/mailutils/reformime.c
@@ -265,9 +265,9 @@ int reformime_main(int argc UNUSED_PARAM, char **argv)
// parse options
// N.B. only -x and -X are supported so far
- opt_complementary = "x--X:X--x" IF_FEATURE_REFORMIME_COMPAT(":m::");
+ opt_complementary = "x--X:X--x";
opts = getopt32(argv,
- "x:X" IF_FEATURE_REFORMIME_COMPAT("deis:r:c:m:h:o:O:"),
+ "x:X" IF_FEATURE_REFORMIME_COMPAT("deis:r:c:m:*h:o:O:"),
&opt_prefix
IF_FEATURE_REFORMIME_COMPAT(, NULL, NULL, &G.opt_charset, NULL, NULL, NULL, NULL)
);
diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c
index 5143fac8f..fb4dbb3da 100644
--- a/mailutils/sendmail.c
+++ b/mailutils/sendmail.c
@@ -247,11 +247,11 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
// parse options
// -v is a counter, -H and -S are mutually exclusive, -a is a list
- opt_complementary = "vv:w+:H--S:S--H:a::";
+ opt_complementary = "vv:H--S:S--H";
// N.B. since -H and -S are mutually exclusive they do not interfere in opt_connect
// -a is for ssmtp (http://downloads.openwrt.org/people/nico/man/man8/ssmtp.8.html) compatibility,
// it is still under development.
- opts = getopt32(argv, "tf:o:iw:H:S:a::v", &opt_from, NULL,
+ opts = getopt32(argv, "tf:o:iw:+H:S:a:*:v", &opt_from, NULL,
&timeout, &opt_connect, &opt_connect, &list, &verbose);
//argc -= optind;
argv += optind;
diff --git a/miscutils/conspy.c b/miscutils/conspy.c
index f6468c116..e80158e39 100644
--- a/miscutils/conspy.c
+++ b/miscutils/conspy.c
@@ -388,8 +388,8 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
INIT_G();
strcpy(G.vcsa_name, DEV_VCSA);
- opt_complementary = "x+:y+"; // numeric params
- opts = getopt32(argv, "vcQsndfFx:y:", &G.x, &G.y);
+ // numeric params
+ opts = getopt32(argv, "vcQsndfFx:+y:+", &G.x, &G.y);
argv += optind;
ttynum = 0;
if (argv[0]) {
diff --git a/miscutils/ionice.c b/miscutils/ionice.c
index 0c14256ab..5fcb653a8 100644
--- a/miscutils/ionice.c
+++ b/miscutils/ionice.c
@@ -60,9 +60,8 @@ int ionice_main(int argc UNUSED_PARAM, char **argv)
};
/* Numeric params */
- opt_complementary = "n+:c+:p+";
/* '+': stop at first non-option */
- opt = getopt32(argv, "+n:c:p:", &pri, &ioclass, &pid);
+ opt = getopt32(argv, "+n:+c:+p:+", &pri, &ioclass, &pid);
argv += optind;
if (opt & OPT_c) {
diff --git a/miscutils/microcom.c b/miscutils/microcom.c
index d9e8f9187..dfc9771d8 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -64,8 +64,7 @@ int microcom_main(int argc UNUSED_PARAM, char **argv)
unsigned opts;
// fetch options
- opt_complementary = "=1:s+:d+:t+"; // exactly one arg, numeric options
- opts = getopt32(argv, "Xs:d:t:", &speed, &delay, &timeout);
+ opts = getopt32(argv, "Xs:+d:+t:+", &speed, &delay, &timeout);
// argc -= optind;
argv += optind;
diff --git a/miscutils/timeout.c b/miscutils/timeout.c
index 9d56593ba..8df9ff0fd 100644
--- a/miscutils/timeout.c
+++ b/miscutils/timeout.c
@@ -52,9 +52,8 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
/* -p option is not documented, it is needed to support NOMMU. */
/* -t SECONDS; -p PARENT_PID */
- opt_complementary = "t+" USE_FOR_NOMMU(":p+");
/* '+': stop at first non-option */
- getopt32(argv, "+s:t:" USE_FOR_NOMMU("p:"), &opt_s, &timeout, &parent);
+ getopt32(argv, "+s:t:+" USE_FOR_NOMMU("p:+"), &opt_s, &timeout, &parent);
/*argv += optind; - no, wait for bb_daemonize_or_rexec! */
signo = get_signum(opt_s);
if (signo < 0)
diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c
index 4364bc807..8e55e9577 100644
--- a/miscutils/ubi_tools.c
+++ b/miscutils/ubi_tools.c
@@ -134,8 +134,8 @@ int ubi_tools_main(int argc UNUSED_PARAM, char **argv)
#define OPTION_a (1 << 5)
#define OPTION_t (1 << 6)
if (do_mkvol) {
- opt_complementary = "-1:d+:n+:a+:O+";
- opts = getopt32(argv, "md:n:N:s:a:t:O:",
+ opt_complementary = "-1";
+ opts = getopt32(argv, "md:+n:+N:s:a:+t:O:+",
&dev_num, &vol_id,
&vol_name, &size_bytes_str, &alignment, &type,
&vid_hdr_offset
@@ -146,8 +146,8 @@ int ubi_tools_main(int argc UNUSED_PARAM, char **argv)
opts = getopt32(argv, "s:at", &size_bytes_str);
opts *= OPTION_s;
} else {
- opt_complementary = "-1:m+:d+:n+:a+";
- opts = getopt32(argv, "m:d:n:N:s:a:t:",
+ opt_complementary = "-1";
+ opts = getopt32(argv, "m:+d:+n:+N:s:a:+t:",
&mtd_num, &dev_num, &vol_id,
&vol_name, &size_bytes_str, &alignment, &type
);
diff --git a/networking/arping.c b/networking/arping.c
index 4f207eaa5..46bd65e36 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -295,8 +295,8 @@ int arping_main(int argc UNUSED_PARAM, char **argv)
/* Dad also sets quit_on_reply.
* Advert also sets unsolicited.
*/
- opt_complementary = "=1:Df:AU:c+";
- opt = getopt32(argv, "DUAqfbc:w:I:s:",
+ opt_complementary = "=1:Df:AU";
+ opt = getopt32(argv, "DUAqfbc:+w:I:s:",
&count, &str_timeout, &device, &source);
if (opt & 0x80) /* -w: timeout */
timeout_us = xatou_range(str_timeout, 0, INT_MAX/2000000) * 1000000 + 500000;
diff --git a/networking/ftpd.c b/networking/ftpd.c
index 360d1e6be..4cbb9b6fe 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -1130,11 +1130,11 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv)
abs_timeout = 1 * 60 * 60;
verbose_S = 0;
G.timeout = 2 * 60;
- opt_complementary = "t+:T+:vv:SS";
+ opt_complementary = "vv:SS";
#if BB_MMU
- opts = getopt32(argv, "vS" IF_FEATURE_FTP_WRITE("w") "t:T:", &G.timeout, &abs_timeout, &G.verbose, &verbose_S);
+ opts = getopt32(argv, "vS" IF_FEATURE_FTP_WRITE("w") "t:+T:+", &G.timeout, &abs_timeout, &G.verbose, &verbose_S);
#else
- opts = getopt32(argv, "l1AvS" IF_FEATURE_FTP_WRITE("w") "t:T:", &G.timeout, &abs_timeout, &G.verbose, &verbose_S);
+ opts = getopt32(argv, "l1AvS" IF_FEATURE_FTP_WRITE("w") "t:+T:+", &G.timeout, &abs_timeout, &G.verbose, &verbose_S);
if (opts & (OPT_l|OPT_1)) {
/* Our secret backdoor to ls */
/* TODO: pass --group-directories-first? would be nice, but ls doesn't do that yet */
diff --git a/networking/ifplugd.c b/networking/ifplugd.c
index f0defb5c8..28c49e218 100644
--- a/networking/ifplugd.c
+++ b/networking/ifplugd.c
@@ -107,9 +107,9 @@ enum {
#endif
};
#if ENABLE_FEATURE_PIDFILE
-# define OPTION_STR "+ansfFi:r:It:u:d:m:pqlx:Mk"
+# define OPTION_STR "+ansfFi:r:It:+u:+d:+m:pqlx:Mk"
#else
-# define OPTION_STR "+ansfFi:r:It:u:d:m:pqlx:M"
+# define OPTION_STR "+ansfFi:r:It:+u:+d:+m:pqlx:M"
#endif
enum { // interface status
@@ -560,7 +560,6 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv)
INIT_G();
- opt_complementary = "t+:u+:d+";
opts = getopt32(argv, OPTION_STR,
&G.iface, &G.script_name, &G.poll_time, &G.delay_up,
&G.delay_down, &G.api_mode, &G.extra_arg);
diff --git a/networking/inetd.c b/networking/inetd.c
index 8d44b5198..f9295e38b 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -1153,8 +1153,8 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
if (real_uid != 0) /* run by non-root user */
config_filename = NULL;
- opt_complementary = "R+:q+"; /* -q N, -R N */
- opt = getopt32(argv, "R:feq:", &max_concurrency, &global_queuelen);
+ /* -q N, -R N */
+ opt = getopt32(argv, "R:+feq:+", &max_concurrency, &global_queuelen);
argv += optind;
//argc -= optind;
if (argv[0])
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c
index 471ae1a12..192e42fe5 100644
--- a/networking/nc_bloaty.c
+++ b/networking/nc_bloaty.c
@@ -794,8 +794,8 @@ int nc_main(int argc UNUSED_PARAM, char **argv)
e_found:
// -g -G -t -r deleted, unimplemented -a deleted too
- opt_complementary = "?2:vv:ll:w+"; /* max 2 params; -v and -l are counters; -w N */
- getopt32(argv, "np:s:uvw:" IF_NC_SERVER("lk")
+ opt_complementary = "?2:vv:ll"; /* max 2 params; -v and -l are counters; -w N */
+ getopt32(argv, "np:s:uvw:+" IF_NC_SERVER("lk")
IF_NC_EXTRA("i:o:z"),
&str_p, &str_s, &o_wait
IF_NC_EXTRA(, &str_i, &str_o), &o_verbose IF_NC_SERVER(, &cnt_l));
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 8e7175063..130cef0af 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2197,11 +2197,11 @@ static NOINLINE void ntp_init(char **argv)
/* Parse options */
peers = NULL;
- opt_complementary = "dd:p::wn" /* -d: counter; -p: list; -w implies -n */
+ opt_complementary = "dd:wn" /* -d: counter; -p: list; -w implies -n */
IF_FEATURE_NTPD_SERVER(":Il"); /* -I implies -l */
opts = getopt32(argv,
"nqNx" /* compat */
- "wp:S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */
+ "wp:*S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */
IF_FEATURE_NTPD_SERVER("I:") /* compat */
"d" /* compat */
"46aAbgL", /* compat, ignored */
diff --git a/networking/ping.c b/networking/ping.c
index d8767a39f..82d5b7a85 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -341,7 +341,7 @@ static int common_ping_main(sa_family_t af, char **argv)
/* Full(er) version */
-#define OPT_STRING ("qvc:s:t:w:W:I:np:4" IF_PING6("6"))
+#define OPT_STRING ("qvc:+s:t:+w:+W:+I:np:4" IF_PING6("6"))
enum {
OPT_QUIET = 1 << 0,
OPT_VERBOSE = 1 << 1,
@@ -865,7 +865,7 @@ static int common_ping_main(int opt, char **argv)
INIT_G();
/* exactly one argument needed; -v and -q don't mix; -c NUM, -t NUM, -w NUM, -W NUM */
- opt_complementary = "=1:q--v:v--q:c+:t+:w+:W+";
+ opt_complementary = "=1:q--v:v--q";
opt |= getopt32(argv, OPT_STRING, &pingcount, &str_s, &opt_ttl, &deadline, &timeout, &str_I, &str_p);
if (opt & OPT_s)
datalen = xatou16(str_s); // -s
diff --git a/networking/tcpudp.c b/networking/tcpudp.c
index 31bc70459..fbd1f1c45 100644
--- a/networking/tcpudp.c
+++ b/networking/tcpudp.c
@@ -232,9 +232,9 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
tcp = (applet_name[0] == 't');
/* 3+ args, -i at most once, -p implies -h, -v is counter, -b N, -c N */
- opt_complementary = "-3:i--i:ph:vv:b+:c+";
+ opt_complementary = "-3:i--i:ph:vv";
#ifdef SSLSVD
- opts = getopt32(argv, "+c:C:i:x:u:l:Eb:hpt:vU:/:Z:K:",
+ opts = getopt32(argv, "+c:+C:i:x:u:l:Eb:+hpt:vU:/:Z:K:",
&cmax, &str_C, &instructs, &instructs, &user, &preset_local_hostname,
&backlog, &str_t, &ssluser, &root, &cert, &key, &verbose
);
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 13c36aa46..2fbdc3bb3 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -496,12 +496,12 @@ int telnetd_main(int argc UNUSED_PARAM, char **argv)
INIT_G();
/* -w NUM, and implies -F. -w and -i don't mix */
- IF_FEATURE_TELNETD_INETD_WAIT(opt_complementary = "wF:w+:i--w:w--i";)
+ IF_FEATURE_TELNETD_INETD_WAIT(opt_complementary = "wF:i--w:w--i";)
/* Even if !STANDALONE, we accept (and ignore) -i, thus people
* don't need to guess whether it's ok to pass -i to us */
opt = getopt32(argv, "f:l:Ki"
IF_FEATURE_TELNETD_STANDALONE("p:b:F")
- IF_FEATURE_TELNETD_INETD_WAIT("Sw:"),
+ IF_FEATURE_TELNETD_INETD_WAIT("Sw:+"),
&G.issuefile, &G.loginpath
IF_FEATURE_TELNETD_STANDALONE(, &opt_portnbr, &opt_bindaddr)
IF_FEATURE_TELNETD_INETD_WAIT(, &sec_linger)
diff --git a/networking/traceroute.c b/networking/traceroute.c
index eee4f8873..e43a36dc7 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -294,7 +294,7 @@
#define OPT_STRING \
"FIlnrdvxt:i:m:p:q:s:w:z:f:" \
- IF_FEATURE_TRACEROUTE_SOURCE_ROUTE("g:") \
+ IF_FEATURE_TRACEROUTE_SOURCE_ROUTE("g:*") \
"4" IF_TRACEROUTE6("6")
enum {
OPT_DONT_FRAGMNT = (1 << 0), /* F */
@@ -819,7 +819,7 @@ common_traceroute_main(int op, char **argv)
INIT_G();
/* minimum 1 arg */
- opt_complementary = "-1:x-x" IF_FEATURE_TRACEROUTE_SOURCE_ROUTE(":g::");
+ opt_complementary = "-1:x-x";
op |= getopt32(argv, OPT_STRING
, &tos_str, &device, &max_ttl_str, &port_str, &nprobes_str
, &source, &waittime_str, &pausemsecs_str, &first_ttl_str
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 12f8f1125..6ff040d9e 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -944,9 +944,9 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
/* Parse command line */
/* O,x: list; -T,-t,-A take numeric param */
- opt_complementary = "O::x::T+:t+:A+" IF_UDHCP_VERBOSE(":vv") ;
+ IF_UDHCP_VERBOSE(opt_complementary = "vv";)
IF_LONG_OPTS(applet_long_options = udhcpc6_longopts;)
- opt = getopt32(argv, "i:np:qRr:s:T:t:SA:O:ox:f"
+ opt = getopt32(argv, "i:np:qRr:s:T:+t:+SA:+O:*ox:*f"
USE_FOR_MMU("b")
///IF_FEATURE_UDHCPC_ARPING("a")
IF_FEATURE_UDHCP_PORT("P:")
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index e58acbaca..8a16e987d 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1283,9 +1283,9 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
/* Parse command line */
/* O,x: list; -T,-t,-A take numeric param */
- opt_complementary = "O::x::T+:t+:A+" IF_UDHCP_VERBOSE(":vv") ;
+ IF_UDHCP_VERBOSE(opt_complementary = "vv";)
IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
- opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB"
+ opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB"
USE_FOR_MMU("b")
IF_FEATURE_UDHCPC_ARPING("a::")
IF_FEATURE_UDHCP_PORT("P:")
diff --git a/networking/wget.c b/networking/wget.c
index 28c12540b..37950ed39 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -1268,9 +1268,8 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0")
applet_long_options = wget_longopts;
#endif
opt_complementary = "-1" /* at least one URL */
- IF_FEATURE_WGET_TIMEOUT(":T+") /* -T NUM */
IF_FEATURE_WGET_LONG_OPTIONS(":\xff::"); /* --header is a list */
- getopt32(argv, "csqO:P:Y:U:T:"
+ getopt32(argv, "csqO:P:Y:U:T:+"
/*ignored:*/ "t:"
/*ignored:*/ "n::"
/* wget has exactly four -n<letter> opts, all of which we can ignore:
diff --git a/networking/whois.c b/networking/whois.c
index 6ba8dfd20..c9dfcf5ee 100644
--- a/networking/whois.c
+++ b/networking/whois.c
@@ -167,8 +167,8 @@ int whois_main(int argc UNUSED_PARAM, char **argv)
int port = 43;
const char *host = "whois.iana.org";
- opt_complementary = "-1:p+";
- getopt32(argv, "ih:p:", &host, &port);
+ opt_complementary = "-1";
+ getopt32(argv, "ih:p:+", &host, &port);
argv += optind;
do {
diff --git a/procps/pgrep.c b/procps/pgrep.c
index 1c7c7c48b..1c594cf96 100644
--- a/procps/pgrep.c
+++ b/procps/pgrep.c
@@ -106,8 +106,7 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv)
/* Parse remaining options */
ppid2match = -1;
sid2match = -1;
- opt_complementary = "s+:P+"; /* numeric opts */
- opt = getopt32(argv, "vlfxons:P:", &sid2match, &ppid2match);
+ opt = getopt32(argv, "vlfxons:+P:+", &sid2match, &ppid2match);
argv += optind;
if (pkill && OPT_LIST) { /* -l: print the whole signal list */
diff --git a/procps/pidof.c b/procps/pidof.c
index 6d7b59109..6d265667f 100644
--- a/procps/pidof.c
+++ b/procps/pidof.c
@@ -51,13 +51,12 @@ int pidof_main(int argc UNUSED_PARAM, char **argv)
unsigned opt;
#if ENABLE_FEATURE_PIDOF_OMIT
llist_t *omits = NULL; /* list of pids to omit */
- opt_complementary = "o::";
#endif
/* do unconditional option parsing */
opt = getopt32(argv, ""
IF_FEATURE_PIDOF_SINGLE ("s")
- IF_FEATURE_PIDOF_OMIT("o:", &omits));
+ IF_FEATURE_PIDOF_OMIT("o:*", &omits));
#if ENABLE_FEATURE_PIDOF_OMIT
/* fill omit list. */
diff --git a/procps/ps.c b/procps/ps.c
index 08dfce12e..ce638261a 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -593,8 +593,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv)
* procps v3.2.7 supports -T and shows tids as SPID column,
* it also supports -L where it shows tids as LWP column.
*/
- opt_complementary = "o::";
- opt = getopt32(argv, "Zo:aAdefl"IF_FEATURE_SHOW_THREADS("T"), &opt_o);
+ opt = getopt32(argv, "Zo:*aAdefl"IF_FEATURE_SHOW_THREADS("T"), &opt_o);
if (opt_o) {
do {
parse_o(llist_pop(&opt_o));
diff --git a/procps/watch.c b/procps/watch.c
index 97aa04767..20859c3cd 100644
--- a/procps/watch.c
+++ b/procps/watch.c
@@ -51,9 +51,9 @@ int watch_main(int argc UNUSED_PARAM, char **argv)
xopen("/dev/null", O_RDONLY);
#endif
- opt_complementary = "-1:n+"; // at least one param; -n NUM
+ opt_complementary = "-1"; // at least one param; -n NUM
// "+": stop at first non-option (procps 3.x only)
- opt = getopt32(argv, "+dtn:", &period);
+ opt = getopt32(argv, "+dtn:+", &period);
argv += optind;
// watch from both procps 2.x and 3.x does concatenation. Example:
diff --git a/runit/chpst.c b/runit/chpst.c
index 7fe5151db..3769af25e 100644
--- a/runit/chpst.c
+++ b/runit/chpst.c
@@ -300,8 +300,8 @@ int chpst_main(int argc UNUSED_PARAM, char **argv)
// FIXME: can we live with int-sized limits?
// can we live with 40000 days?
// if yes -> getopt converts strings to numbers for us
- opt_complementary = "-1:a+:c+:d+:f+:l+:m+:o+:p+:r+:s+:t+";
- opt = getopt32(argv, "+a:c:d:f:l:m:o:p:r:s:t:u:U:e:"
+ opt_complementary = "-1";
+ opt = getopt32(argv, "+a:+c:+d:+f:+l:+m:+o:+p:+r:+s:+t:+u:U:e:"
IF_CHPST("/:n:vP012"),
&limita, &limitc, &limitd, &limitf, &limitl,
&limitm, &limito, &limitp, &limitr, &limits, &limitt,
diff --git a/runit/sv.c b/runit/sv.c
index 2a256a6b4..37df9a929 100644
--- a/runit/sv.c
+++ b/runit/sv.c
@@ -474,8 +474,8 @@ int sv_main(int argc UNUSED_PARAM, char **argv)
x = getenv("SVWAIT");
if (x) waitsec = xatou(x);
- opt_complementary = "w+:vv"; /* -w N, -v is a counter */
- getopt32(argv, "w:v", &waitsec, &verbose);
+ opt_complementary = "vv"; /* -w N, -v is a counter */
+ getopt32(argv, "w:+v", &waitsec, &verbose);
argv += optind;
action = *argv++;
if (!action || !*argv) bb_show_usage();
diff --git a/selinux/setfiles.c b/selinux/setfiles.c
index 51a7e63bd..c9597d54e 100644
--- a/selinux/setfiles.c
+++ b/selinux/setfiles.c
@@ -577,13 +577,13 @@ int setfiles_main(int argc UNUSED_PARAM, char **argv)
set_matchpathcon_flags(matchpathcon_flags);
- opt_complementary = "e::vv:v--p:p--v:v--q:q--v";
+ opt_complementary = "vv:v--p:p--v:v--q:q--v";
/* Option order must match OPT_x definitions! */
if (applet_name[0] == 'r') { /* restorecon */
- flags = getopt32(argv, "de:f:ilnpqrsvo:FWR",
+ flags = getopt32(argv, "de:*f:ilnpqrsvo:FWR",
&exclude_dir, &input_filename, &out_filename, &verbose);
} else { /* setfiles */
- flags = getopt32(argv, "de:f:ilnpqr:svo:FW"
+ flags = getopt32(argv, "de:*f:ilnpqr:svo:FW"
IF_FEATURE_SETFILES_CHECK_OPTION("c:"),
&exclude_dir, &input_filename, &rootpath, &out_filename,
IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,)
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index a119bdeae..ae0840bff 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -342,7 +342,7 @@ enum {
#define OPTION_STR "m:nO:l:S" \
IF_FEATURE_ROTATE_LOGFILE("s:" ) \
IF_FEATURE_ROTATE_LOGFILE("b:" ) \
- IF_FEATURE_REMOTE_LOG( "R:" ) \
+ IF_FEATURE_REMOTE_LOG( "R:*") \
IF_FEATURE_REMOTE_LOG( "L" ) \
IF_FEATURE_IPC_SYSLOG( "C::") \
IF_FEATURE_SYSLOGD_DUP( "D" ) \
@@ -1108,8 +1108,8 @@ int syslogd_main(int argc UNUSED_PARAM, char **argv)
INIT_G();
- /* No non-option params, -R can occur multiple times */
- opt_complementary = "=0" IF_FEATURE_REMOTE_LOG(":R::");
+ /* No non-option params */
+ opt_complementary = "=0";
opts = getopt32(argv, OPTION_STR, OPTION_PARAM);
#if ENABLE_FEATURE_REMOTE_LOG
while (remoteAddrList) {
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index e543446c1..50e8a0fce 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -34,8 +34,7 @@ int dmesg_main(int argc UNUSED_PARAM, char **argv)
OPT_r = 1 << 3
};
- opt_complementary = "s+:n+"; /* numeric */
- opts = getopt32(argv, "cs:n:r", &len, &level);
+ opts = getopt32(argv, "cs:+n:+r", &len, &level);
if (opts & OPT_n) {
if (klogctl(8, NULL, (long) level))
bb_perror_msg_and_die("klogctl");
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index f49ce95a4..6391f9bd9 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -2919,8 +2919,7 @@ int fdisk_main(int argc UNUSED_PARAM, char **argv)
close_dev_fd(); /* needed: fd 3 must not stay closed */
- opt_complementary = "b+:C+:H+:S+"; /* numeric params */
- opt = getopt32(argv, "b:C:H:lS:u" IF_FEATURE_FDISK_BLKSIZE("s"),
+ opt = getopt32(argv, "b:+C:+H:+lS:+u" IF_FEATURE_FDISK_BLKSIZE("s"),
&sector_size, &user_cylinders, &user_heads, &user_sectors);
argv += optind;
if (opt & OPT_b) {
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index b9dadf13c..18d490987 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -397,8 +397,7 @@ int getopt_main(int argc, char **argv)
opt = getopt32(argv, "+o:n:qQs:Tu", &optstr, &name, &s_arg);
#else
applet_long_options = getopt_longopts;
- opt_complementary = "l::";
- opt = getopt32(argv, "+o:n:qQs:Tual:",
+ opt = getopt32(argv, "+o:n:qQs:Tual:*",
&optstr, &name, &s_arg, &l_arg);
/* Effectuate the read options for the applet itself */
while (l_arg) {
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
index f91a0b4bf..413e7aa15 100644
--- a/util-linux/mkfs_ext2.c
+++ b/util-linux/mkfs_ext2.c
@@ -244,8 +244,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
// using global "option_mask32" instead of local "opts":
// we are register starved here
- opt_complementary = "-1:b+:i+:I+:m+";
- /*opts =*/ getopt32(argv, "cl:b:f:i:I:J:G:N:m:o:g:L:M:O:r:E:T:U:jnqvFS",
+ /*opts =*/ getopt32(argv, "cl:b:+f:i:+I:+J:G:N:m:+o:g:L:M:O:r:E:T:U:jnqvFS",
/*lbfi:*/ NULL, &bs, NULL, &bpi,
/*IJGN:*/ &user_inodesize, NULL, NULL, NULL,
/*mogL:*/ &reserved_percent, NULL, NULL, &label,
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 88d797584..aaabf8453 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -604,8 +604,7 @@ int mkfs_minix_main(int argc UNUSED_PARAM, char **argv)
bb_error_msg_and_die("bad inode size");
#endif
- opt_complementary = "n+"; /* -n N */
- opt = getopt32(argv, "ci:l:n:v", &str_i, &listfile, &G.namelen);
+ opt = getopt32(argv, "ci:l:n:+v", &str_i, &listfile, &G.namelen);
argv += optind;
//if (opt & 1) -c
if (opt & 2) G.req_nr_inodes = xatoul(str_i); // -i
diff --git a/util-linux/mkfs_reiser.c b/util-linux/mkfs_reiser.c
index 56c8f0ab5..0a31ee44f 100644
--- a/util-linux/mkfs_reiser.c
+++ b/util-linux/mkfs_reiser.c
@@ -169,8 +169,8 @@ int mkfs_reiser_main(int argc UNUSED_PARAM, char **argv)
// using global "option_mask32" instead of local "opts":
// we are register starved here
- opt_complementary = "-1:b+";
- /*opts =*/ getopt32(argv, "b:j:s:o:t:B:h:u:l:fqd",
+ opt_complementary = "-1";
+ /*opts =*/ getopt32(argv, "b:+j:s:o:t:B:h:u:l:fqd",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &label);
argv += optind; // argv[0] -- device
diff --git a/util-linux/mount.c b/util-linux/mount.c
index cef4f7415..13590ceb4 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -268,7 +268,7 @@ enum {
};
-#define OPTION_STR "o:t:rwanfvsiO:" IF_FEATURE_MOUNT_OTHERTAB("T:")
+#define OPTION_STR "o:*t:rwanfvsiO:" IF_FEATURE_MOUNT_OTHERTAB("T:")
enum {
OPT_o = (1 << 0),
OPT_t = (1 << 1),
@@ -2167,7 +2167,7 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
// Parse remaining options
// Max 2 params; -o is a list, -v is a counter
- opt_complementary = "?2o::" IF_FEATURE_MOUNT_VERBOSE("vv");
+ opt_complementary = "?2" IF_FEATURE_MOUNT_VERBOSE("vv");
opt = getopt32(argv, OPTION_STR, &lst_o, &fstype, &O_optmatch
IF_FEATURE_MOUNT_OTHERTAB(, &fstabname)
IF_FEATURE_MOUNT_VERBOSE(, &verbose));
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c
index a64540464..345b676ba 100644
--- a/util-linux/readprofile.c
+++ b/util-linux/readprofile.c
@@ -99,8 +99,7 @@ int readprofile_main(int argc UNUSED_PARAM, char **argv)
proFile = defaultpro;
mapFile = defaultmap;
- opt_complementary = "M+"; /* -M N */
- opt = getopt32(argv, "M:m:p:nabsirv", &multiplier, &mapFile, &proFile);
+ opt = getopt32(argv, "M:+m:p:nabsirv", &multiplier, &mapFile, &proFile);
if (opt & (OPT_M|OPT_r)) { /* mult or reset, or both */
int fd, to_write;