[BusyBox] re: long args in bb_getopt_ulflags()

Paul Fox pgf at brightstareng.com
Mon Jan 31 16:36:33 UTC 2005


 > Paul,
 > 
 > > hi tito.  i'm sorry, i was unclear in my statement above.  yes,
 > > your example works fine, but "--version" is just a flag option --
 > > there's no optarg associated with it.  i should have said:  if a
 > > long option needs to have an argument, and there's no short
 > > option equivalent for that option, then you can't get the
 > > argument using bb_getop_ulflags().
 > 
 > Its not problem.
 > See networking/wget.c
 > 
 > static const struct option wget_long_options[] = {
 >          { "continue",        0, NULL, 'c' },
 >          { "quiet",           0, NULL, 'q' },
 >          { "passive-ftp",     0, NULL, 139 },
 >          { "output-document", 1, NULL, 'O' },
 >          { "header",              1, NULL, 131 },
 >          { "directory-prefix",1, NULL, 'P' },
 >          { "proxy",           1, NULL, 'Y' },
 >          { 0,                 0, 0, 0 }
 > };
 > 
 >          bb_opt_complementaly = "\203*";
 >          bb_applet_long_options = wget_long_options;
 >          opt = bb_getopt_ulflags(argc, argv, "cq\213O:\203:P:Y:", ...
 > 


eewwww, yuck.

i thought of doing this, but for some reason i assumed that
preserving 8-bit cleanliness was a goal in the new millenium. :-)
guess i was wrong.

do people really think this is okay?  to clarify:  the code vodz
has quoted uses getopt characters with the high bit set to
represent the short-option version of options which have only
long-option representations.  presumably if one could enter those
characters (octal 203 and 213) on the command line, one would get
the --header and --passive-ftp functionality.

wouldn't it be better to provide a proper option parsing api?

paul

[ p.s.  and please -- in the above example, why on earth would someone
write the constant as "139" in one place, and as "\213" only 10
lines later???  that's just dumb.  can we make the codebase any
harder to read?  sheesh.  ]

paul
=---------------------
 paul fox, pgf at brightstareng.com



More information about the busybox mailing list