diff options
-rw-r--r-- | Changes | 3 | ||||
-rw-r--r-- | lib/Monitoring/Plugin/Getopt.pm | 16 |
2 files changed, 12 insertions, 7 deletions
@@ -1,5 +1,8 @@ | |||
1 | Revision history for Perl module Monitoring::Plugin. | 1 | Revision history for Perl module Monitoring::Plugin. |
2 | 2 | ||
3 | next: | ||
4 | - fix "Redundant argument in sprintf" in perl 5.21 (RT #103214) | ||
5 | |||
3 | 0.39 | 6 | 0.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) |
167 | sub _usage | 168 | sub _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 |