[BusyBox] Re: busybox-cvs Digest, Vol 29, Issue 4

Tito farmatito at tiscali.it
Tue Aug 2 20:25:26 UTC 2005


On Tuesday 02 August 2005 15:29, Paul Fox wrote:

snip

>  > > +		/* there is no way for bb_getopt_ulflags() to
>  > > +		 * return us the argument string for long options
>  > > +		 * which don't have a short option equivalent.
>  > 
>  > Its False. Have way: using non printable short option.
> 
> yes, you and i talked about this before, and i remember your
> solution.  i consider it unacceptable to write programs which
> have hidden unexpected features on the command line.  if the
> option processing api changes, i'm happy to change the ls code to
> use it.
> 

 longopts is a pointer to the first element of an array of struct option
 declared in <getopt.h> as

          struct option {
              const char *name;
              int has_arg;
              int *flag;
              int val;    /* not char */
          };


This is from util-linux2.12a mount:

extern char version[];
static struct option longopts[] = {
	{ "all", 0, 0, 'a' },
	{ "fake", 0, 0, 'f' },
	{ "fork", 0, 0, 'F' },
	{ "help", 0, 0, 'h' },
	{ "no-mtab", 0, 0, 'n' },
	{ "read-only", 0, 0, 'r' },
	{ "ro", 0, 0, 'r' },
	{ "verbose", 0, 0, 'v' },
	{ "version", 0, 0, 'V' },
	{ "read-write", 0, 0, 'w' },
	{ "rw", 0, 0, 'w' },
	{ "options", 1, 0, 'o' },
	{ "test-opts", 1, 0, 'O' },
	{ "pass-fd", 1, 0, 'p' },
	{ "types", 1, 0, 't' },
	{ "bind", 0, 0, 128 },
	{ "replace", 0, 0, 129 },
	{ "after", 0, 0, 130 },
	{ "before", 0, 0, 131 },
	{ "over", 0, 0, 132 },
	{ "move", 0, 0, 133 },
	{ "guess-fstype", 1, 0, 134 },
	{ "rbind", 0, 0, 135 },
	{ "internal-only", 0, 0, 'i' },
	{ NULL, 0, 0, 0 }
}

Seems to me they do it the same way vodz suggests.
If they do why shouldn't we?
Maybe should we pass some negative values instead and use 
#define CHAR_REPLACE   -1

and so on....
Could this be abused from the commandline?

Just an idea and not tested, but worth a try if 
you agree I'll study the case tomorrow as
i'm free.

Ciao,
Tito



More information about the busybox mailing list