- add a few basic tests for pidof(8)
[oweals/busybox.git] / libbb / getopt_ulflags.c
index f620812fa9efeebc5c877be08a0370c9ef7f61de..2e2ee0b6b6242fa5ad9d01db4a6070e3a1b7775d 100644 (file)
@@ -111,7 +111,8 @@ const char *bb_opt_complementally
        found.
 
  "ww"   Adjacent double options have a counter associated which indicates
-    the number of occurances of the option. For example the ps applet needs:
+       the number of occurances of the option.
+       For example the ps applet needs:
        if w is given once, GNU ps sets the width to 132,
        if w is given more than once, it is "unlimited"
 
@@ -133,9 +134,12 @@ const char *bb_opt_complementally
        llist_t *my_b = NULL;
        int verbose_level = 0;
        bb_opt_complementally = "vv:b*:b-c:c-b";
-       bb_getopt_ulflags(argc, argv, "vb:c", &my_b, &verbose_level);
-       while (my_b) { dosomething_with(my_b->data) ; my_b = my_b->link; }
-       if (verbose_level) bb_printf("verbose\n");
+       f = bb_getopt_ulflags(argc, argv, "vb:c", &my_b, &verbose_level);
+       if((f & 2))     // -c after -b unset this -b flag
+         while (my_b) { dosomething_with(my_b->data) ; my_b = my_b->link; }
+       if(my_b)        // but llist stored always if -b found
+               free_llist(my_b);
+       if (verbose_level) bb_printf("verbose level is %d\n", verbose_level);
 
 Special characters:
 
@@ -170,11 +174,11 @@ Special characters:
        convert the arguments as option.
        For example:
 
-       bb_opt_complementally = "-:w";
-       bb_getopt_ulflags(argc, argv, "w");
+       bb_opt_complementally = "-:w-x:x-w";
+       bb_getopt_ulflags(argc, argv, "wx");
 
-       Allows option 'w' to be given without a dash (./program w)
-       as well as with a dash (./program -w).
+       Allows any arguments to be given without a dash (./program w x)
+       as well as with a dash (./program -x). Why unset -w see above.
 
  "~"    A tilde between two options, or between an option and a group
        of options, means that they are mutually exclusive.  Unlike