[BusyBox] re: long args in bb_getopt_ulflags()
Paul Fox
pgf at brightstareng.com
Mon Jan 31 14:31:19 UTC 2005
> > implementing --color was a little more cumbersome than i would
> > have liked. currently there's no way for a long option to be
> > parsed by bb_getopt_ulflags() unless it has a corresponding
> > short option. (you can detect the option, but you can't get it's
> > value.) if i'm wrong about this, perhaps someone (vodz?) can tell
> > me how it's done. otherwise, what i've done is inefficient, but
> > not otherwise horrible.
> >
> > paul
>
> Hi, Paul
> Try it like this example it's easy:
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().
i used the same technique as you've shown to find out that the
"--color" option is _present_. if it is, then a second pass must
be made using getopt_long() in order to retrieve the argument
string. (i might have done this differently, but i wasn't about
to touch the existing arg parsing code in ls.)
paul
=---------------------
paul fox, pgf at brightstareng.com
More information about the busybox
mailing list