aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
Diffstat (limited to 'libbb')
-rw-r--r--libbb/getopt32.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index d4465f899..f5aaa70df 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -217,20 +217,12 @@ Special characters:
217 -b, -c and -f are mutally exclusive and should raise an error 217 -b, -c and -f are mutally exclusive and should raise an error
218 if specified together. In this case you must set 218 if specified together. In this case you must set
219 opt_complementary = "b--cf:c--bf:f--bc". If two of the 219 opt_complementary = "b--cf:c--bf:f--bc". If two of the
220 mutually exclusive options are found, getopt32's 220 mutually exclusive options are found, getopt32 will call
221 return value will have the error flag set (BB_GETOPT_ERROR) so 221 bb_show_usage() and die.
222 that we can check for it:
223
224 if (flags & BB_GETOPT_ERROR)
225 bb_show_usage();
226 222
227 "x--x" Variation of the above, it means that -x option should occur 223 "x--x" Variation of the above, it means that -x option should occur
228 at most once. 224 at most once.
229 225
230 "?" A "?" as the first char in a opt_complementary group means:
231 if BB_GETOPT_ERROR is detected, don't return, call bb_show_usage
232 and exit instead. Next char after '?' can't be a digit.
233
234 "::" A double colon after a char in opt_complementary means that the 226 "::" A double colon after a char in opt_complementary means that the
235 option can occur multiple times. Each occurrence will be saved as 227 option can occur multiple times. Each occurrence will be saved as
236 a llist_t element instead of char*. 228 a llist_t element instead of char*.
@@ -476,11 +468,8 @@ getopt32(int argc, char **argv, const char *applet_opts, ...)
476 if (on_off->opt == 0 && c != 0) 468 if (on_off->opt == 0 && c != 0)
477 bb_show_usage(); 469 bb_show_usage();
478 } 470 }
479 if (flags & on_off->incongruously) { 471 if (flags & on_off->incongruously)
480 if ((spec_flgs & SHOW_USAGE_IF_ERROR)) 472 bb_show_usage();
481 bb_show_usage();
482 flags |= BB_GETOPT_ERROR;
483 }
484 trigger = on_off->switch_on & on_off->switch_off; 473 trigger = on_off->switch_on & on_off->switch_off;
485 flags &= ~(on_off->switch_off ^ trigger); 474 flags &= ~(on_off->switch_off ^ trigger);
486 flags |= on_off->switch_on ^ trigger; 475 flags |= on_off->switch_on ^ trigger;