help-gengetopt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [help-gengetopt] override and multiple options


From: Andre Noll
Subject: Re: [help-gengetopt] override and multiple options
Date: Fri, 12 Dec 2008 14:08:29 +0100
User-agent: Mutt/1.5.9i

On 11:51, Lorenzo Bettini wrote:
> >However, the new set of options are _appended_ to the old values
> >instead. Is this behaviour intended? If it is, is that feature
> >documented anywhere? If it isn't intended, what could be done to fix
> >the situation while retaining backwards compatibility?
> >
> 
> Hi Andre
> 
> I think that this is the intended behavior for multiple options, since 
> multiple options are thought exactly to append other options to the ones 
> already given, thus they should not be overridden;

Even if the override flag is set?

> it is up to the application itself to decide what to do then.

Thanks for the clarification. So if one wants to completely get rid
of any previously given values for a certain option, one has to do
something like

        for (i = 0; i < conf.xxx_given; i++) {
                free(conf.xxx_arg[i]);
                conf.xxx_arg[i] = NULL;
        }
        conf.xxx_given = 0;

before calling cmdline_parser_config_file() for the second time. Is
that the preferred way to achieve this?

> For instance, the -O option can be given many times to the gcc compiler,
> and it will decide that only the last one is the one to apply (at least 
> I think it is like that, in fact, in another program, I was struggling 
> with a prebuilt command line option to the compiler that couldn't be 
> changed and this contained -O2 which makes it hard to debug programs: I 
> then appended -O0 and this solved the problem).

But -O shouldn't be a multiple option at all because it usually does not
make sense to specify -O more than once, no?

Anyway, what about programs that may read its config file more than
once at startup? Consider for example a daemon that rereads its config
file whenever it receives SIGHUP. Does it really make sense that the
override feature appends to the array, making it larger and larger
even in case the options that were declared as multiple (in the ggo
file) haven't changed in the config file?

This being said, I have no problems with the current behaviour as the
workaround in the code above works fine. But it should definitly be
documented.

Andre
-- 
The only person who always got his work done by Friday was Robinson Crusoe

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]