From e70d62aaf96830a6480b147e6c90c30aeef31a54 Mon Sep 17 00:00:00 2001 From: Thomas Guyot-Sionnest Date: Thu, 28 Jun 2012 22:54:38 -0400 Subject: Fix a bug where default file used is not shown When a default file is used but no section is found (ex. below using "bad_section"), the plugin dies with: Invalid section 'bad_section' in config file '' This patch add a function to Nagios::Plugin::Config that returns the last used file, and use it to return a file name when we have none. --- lib/Nagios/Plugin/Getopt.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/Nagios/Plugin/Getopt.pm') diff --git a/lib/Nagios/Plugin/Getopt.pm b/lib/Nagios/Plugin/Getopt.pm index 6432ee0..f910c4b 100644 --- a/lib/Nagios/Plugin/Getopt.pm +++ b/lib/Nagios/Plugin/Getopt.pm @@ -249,6 +249,7 @@ sub _load_config_section # TODO: is this check sane? Does --extra-opts=foo require a [foo] section? ## Nevertheless, if we die as UNKNOWN here we should do the same on default ## file *added eval/_die above*. + $file ||= $Config->np_getfile(); $self->_die("Invalid section '$section' in config file '$file'") unless exists $Config->{$section}; -- cgit v1.2.3-74-g34f1