> On 10.08.2011 1:32, Jens Mueller wrote: > > Hi, > > > > I've added some changes to getopt to change when an options is > > accepted/rejected. I'm going to describe its old behavior in contrast > > with its old behavior. > > > > Consider parsing an option of Type T: > > > > T timeout; > > getopt(args, "t|timeout",&timeout); > > > > Short options (single dash): > > -t v accept (was rejected) > > +1 on this, I recall spending about an hour trying to get why -t v is > not working. Though I dunno why change -tv, I think it's widely used > form and not only for numerics. > > > -t=v accept > > -tv only accept for numeric v (was accepted for all types except > > associative arrays) Strange short options: > > -timeout v reject > > -timeout=v reject (was accepted) > > -timeoutv reject > > Long options (double dash): > > --timeout v accept > > --timeout=v accept > > --timeoutv reject > > Strange long options: > > --t v reject (was accepted) > > --t=v reject (was accepted) > > --tv reject > > > > I would like to know whether you find the new behavior better or if you > > prefer the old. Or even a mix of both. Or none of the above. > > Like all of the above except -tv. > > > The current behavior is quite simple if you remember some simple rules: > > 1. Short options consist of a single dash and a single character. > > 2. Long options consist of two dashes and more than one character. > > 3. Passing short and long options is supported by > > > > <short/long option><space+><value> and<short/long option>=<value> > > > > 4. The form<short option><value> is only supported for numeric values. > > Can't figure out the reason for 4, could you clarify a bit?
Normally, -tv would mean that you passed _two_ flags - the t and v flags. -t2 works because 2 can't be a flag. I'm pretty sure that this proposed behavior is normal. - Jonathan M Davis
