[monitoring-plugin-perl] fix "Redundant argument in sprintf" in perl 5.21 ...
Sven Nierlein
git at monitoring-plugins.org
Sat Apr 11 13:00:05 CEST 2015
Module: monitoring-plugin-perl
Branch: master
Commit: 75391608e1160fafb571225f263ea988934d33ba
Author: Sven Nierlein <sven at nierlein.de>
Date: Sat Apr 11 12:51:33 2015 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugin-perl/commit/?id=7539160
fix "Redundant argument in sprintf" in perl 5.21 (RT #103214)
Signed-off-by: Sven Nierlein <sven at nierlein.de>
---
Changes | 3 +++
lib/Monitoring/Plugin/Getopt.pm | 16 +++++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/Changes b/Changes
index cf82ad7..4e1a654 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
Revision history for Perl module Monitoring::Plugin.
+next:
+ - fix "Redundant argument in sprintf" in perl 5.21 (RT #103214)
+
0.39
- fix help formating when using colons (Evgeni Golov)
diff --git a/lib/Monitoring/Plugin/Getopt.pm b/lib/Monitoring/Plugin/Getopt.pm
index db98567..1740830 100644
--- a/lib/Monitoring/Plugin/Getopt.pm
+++ b/lib/Monitoring/Plugin/Getopt.pm
@@ -152,9 +152,10 @@ sub _options
# Add help_string to @options
if ($help_string =~ m/%s/) {
my $default = defined $arg->{default} ? $arg->{default} : '';
- # We only handle '%s' formats here, so escape everything else
- $help_string =~ s/%(?!s)/%%/g;
- push @options, sprintf($help_string, $default, $default, $default, $default);
+ # We only handle '%s' formats here
+ my $replaced = $help_string;
+ $replaced =~ s|%s|$default|gmx;
+ push @options, $replaced;
} else {
push @options, $help_string;
}
@@ -164,10 +165,11 @@ sub _options
}
# Output for plugin -? (or missing/invalid args)
-sub _usage
-{
- my $self = shift;
- sprintf $self->_attr('usage'), $self->{_attr}->{plugin};
+sub _usage {
+ my $self = shift;
+ my $usage = $self->_attr('usage');
+ $usage =~ s|%s|$self->{_attr}->{plugin}|gmx;
+ return($usage);
}
# Output for plugin -V
More information about the Commits
mailing list