[Nagiosplug-devel] nagios-plugins.ini & argument parsing

Ton Voon ton.voon at altinity.com
Mon Mar 17 11:39:00 CET 2008


On 15 Mar 2008, at 20:17, Thomas Guyot-Sionnest wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 14/03/08 08:01 PM, Thomas Guyot-Sionnest wrote:

> I started implementing this part and fixing bugs in parse_ini.c, and  
> so
> far I went across two big differences in ini handling:
>
> 1. N::P allows '#' to be part of the argument, while parse_ini treat
> them as comments. Since it's a one-line change I left the original
> behavior in parse_ini (mainly because the ini/tests have to be changed
> too) but I really think '#' should be allowed.

So comments can only be entered if # is the first character on a line?  
That sounds like a reasonable restriction.

> 2. N::P seems do do some smart parsing based on getopts... in either
> case it doesn't allow parameters without values (no '=' sign on the
> line) while parse_ini does, and append the '=' is there's one.
>
>
> While I'd be tempted to follow N::P's behavior for #2, this raises one
> question: N::P is able to make the difference between parameters that
> requires arguments and those that don't and could smartly insert an
> empty arg if there's nothing after the '='. This means we wouldn't be
> able to emulate empty arguments in the c plugins as long as we don't
> implement N::P-like argument parsing routines.
>
> Alternatively, I could append an empty argument when there's a '=' and
> keep allowing empty arguments, but for consistency I guess we should
> also allow it in N::P (Moth may want to use the config. This also  
> seems
> to be a violation of the ini standard. In a perfect world we could  
> just
> always add empty arguments but it seems that some backward- 
> compatibility
> stuff fail with that. I could also reject lines missing a '=' and  
> never
> add an argument since there aren't many plugins that require empty  
> args...
>
> So for now I'll follow N::P behavior and never add an empty argument.
> The code isn't even used yet so this is still open for comments.

I'm not following the problem here. Can you provide examples?

Ton

http://www.altinity.com
UK: +44 (0)870 787 9243
US: +1 866 879 9184
Fax: +44 (0)845 280 1725
Skype: tonvoon





More information about the Devel mailing list