summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-03-24 11:38:42 -0700
committerNick Lewis <nick@puppetlabs.com>2011-03-24 11:53:11 -0700
commitf8941b80bb8ba6042dddce02d132abe252756162 (patch)
tree10395e72bdd2d4c0d6ea16ba59d403f16c39a48b /lib/puppet
parent3875b5ba9014a6ba540e51e0ffb411d58aa521e4 (diff)
downloadpuppet-f8941b80bb8ba6042dddce02d132abe252756162.tar.gz
puppet-f8941b80bb8ba6042dddce02d132abe252756162.tar.xz
puppet-f8941b80bb8ba6042dddce02d132abe252756162.zip
(#4769) Fix negative timeout support for newer rubies
In new versions of Ruby, negative timeouts are unsupported. So munge negatives to zero in the parameter. Reviewed-By: Jacob Helwig
Diffstat (limited to 'lib/puppet')
-rwxr-xr-xlib/puppet/type/exec.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index 4458bf081..be0ece023 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -229,19 +229,17 @@ module Puppet
newparam(:timeout) do
desc "The maximum time the command should take. If the command takes
longer than the timeout, the command is considered to have failed
- and will be stopped. Use any negative number to disable the timeout.
+ and will be stopped. Use 0 to disable the timeout.
The time is specified in seconds."
munge do |value|
value = value.shift if value.is_a?(Array)
- if value.is_a?(String)
- unless value =~ /^[-\d.]+$/
- raise ArgumentError, "The timeout must be a number."
- end
- Float(value)
- else
- value
+ begin
+ value = Float(value)
+ rescue ArgumentError => e
+ raise ArgumentError, "The timeout must be a number."
end
+ [value, 0.0].max
end
defaultto 300