we've encountered a problem with flags with gengetopt 2.22.1/2. I know that you don't like flags very much but my app is using 14 flags. (for historical reasons, of course ;) Since it is a business product I couldn't change the option type so easily.
The problem arises when a flag option is set more than once in successive call of getoptions_internal(). In this case update_arg() flips back, eventually reset the flag_given while field_given is incremented twice:
*((int *)field) = !*((int *)field);
I don't know and could not figure out by myself if it is the intended behaviour of gengetopt. Could you help me, please? If I change update_arg() it solve my problem:
The detailed scenario is that config file is parsed first and then the command line. The latter has precedence over the former, that is, command line arguments overrides option values given in config file. In my understanding "override" should mean "confirm" in case of flags at least when different settings are originated from different sources (or different runs of gengetopt_internal()).
Note that we should follow these approach. Otherwise, in reverse order, when override is set to 0, gengetopt raises error if a groupoption is set in both the command line and in the config file. (It might be another issue.)