diff options
Diffstat (limited to 'lib/Monitoring/Plugin')
-rw-r--r-- | lib/Monitoring/Plugin/Getopt.pm | 16 |
1 files changed, 9 insertions, 7 deletions
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 |