summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Nierlein <sven@nierlein.de>2015-04-11 12:51:33 +0200
committerSven Nierlein <sven@nierlein.de>2015-04-11 12:51:33 +0200
commit75391608e1160fafb571225f263ea988934d33ba (patch)
tree898f7e3a689a2021ed4d4cf0536308aaade51859
parent4a52ac0ade65d6933ae1ca73d304534657031ca6 (diff)
downloadmonitoring-plugin-perl-75391608e1160fafb571225f263ea988934d33ba.tar.gz
fix "Redundant argument in sprintf" in perl 5.21 (RT #103214)
Signed-off-by: Sven Nierlein <sven@nierlein.de>
-rw-r--r--Changes3
-rw-r--r--lib/Monitoring/Plugin/Getopt.pm16
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 @@
1Revision history for Perl module Monitoring::Plugin. 1Revision history for Perl module Monitoring::Plugin.
2 2
3next:
4 - fix "Redundant argument in sprintf" in perl 5.21 (RT #103214)
5
30.39 60.39
4 - fix help formating when using colons (Evgeni Golov) 7 - fix help formating when using colons (Evgeni Golov)
5 8
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
152 # Add help_string to @options 152 # Add help_string to @options
153 if ($help_string =~ m/%s/) { 153 if ($help_string =~ m/%s/) {
154 my $default = defined $arg->{default} ? $arg->{default} : ''; 154 my $default = defined $arg->{default} ? $arg->{default} : '';
155 # We only handle '%s' formats here, so escape everything else 155 # We only handle '%s' formats here
156 $help_string =~ s/%(?!s)/%%/g; 156 my $replaced = $help_string;
157 push @options, sprintf($help_string, $default, $default, $default, $default); 157 $replaced =~ s|%s|$default|gmx;
158 push @options, $replaced;
158 } else { 159 } else {
159 push @options, $help_string; 160 push @options, $help_string;
160 } 161 }
@@ -164,10 +165,11 @@ sub _options
164} 165}
165 166
166# Output for plugin -? (or missing/invalid args) 167# Output for plugin -? (or missing/invalid args)
167sub _usage 168sub _usage {
168{ 169 my $self = shift;
169 my $self = shift; 170 my $usage = $self->_attr('usage');
170 sprintf $self->_attr('usage'), $self->{_attr}->{plugin}; 171 $usage =~ s|%s|$self->{_attr}->{plugin}|gmx;
172 return($usage);
171} 173}
172 174
173# Output for plugin -V 175# Output for plugin -V