[Nagiosplug-devel] Perl Modul Nagios::Plugin and extra-opts - request for comments
Stephan
Stephan at quantentunnel.de
Wed May 30 22:59:03 CEST 2012
Hi!
Holger Weiß asked me to introduce here what I intend to do.
I lately started to use Nagios::Plugin for a plugin I developed at work.
I came across the --extra-opts parameter and thought that this could be
very helpful.
Unfortunately I seem to found a bug - or at least - inconsistant behaviour.
When you pass on commandline something like --opt "test value" you get
in your variable:
test value
But if you put into the extra-opts file
opt="test value"
you get
"test value"
Okay, I could live with the plugin not removing the quotes, so I put
into the extra-opts file
opt=test vale
But guess what I got:
"test value"
So N::P is introducing quotes here.
So my first idea is to get rid of those quotes.
Unfortunately this will break some of the tests, as they rely on the sub
_cmdline which generates, from the internal options array, a commandline.
But this sub is, as far as I can see, only used for this test and
nowhere else.
Additionally the quoting is done wrong or at least for an OS I don't
know as quotes inside the string are not escaped. So this
opt=a 2.5" hard disc
becomes
"a 2.5" hard disc"
So the questions I have are:
1) For what reason was the quoting introduced - except for the tests?
2) For which platform is it intended? For sure no *IX
3) Is it required?
I'd vote for getting rid of the quoting.
My second idea is to introduce multiline values in the extra-opts file.
This would simply be done in the usual way, by putting a backslash "\"
as last charater of the line. All the lines will be concatenated by a
single space after first triming them. So
opt=multi \
line \
value
would become
multi line value
Last but not lest I'd like to introduce a HERE-document like syntax in
conformance to Config::General. Example:
opt=<<HERE
line 1
line 2
line 3
HERE
would become
line1\nline 2\nline 3\n
and, as the amount of whitespace before the end-marker is removed from
all the lines:
opt=<<HERE
line 1
line 2
line 3
HERE
would become
line1\n line2\nline 3\n
What do you think about my ideas?
More information about the Devel
mailing list