From a0f86644cd254697b4c875a7a8e34fbb1010cf3a Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 12 Oct 2016 16:11:02 +0100 Subject: (MODULES-3969) Update getvar to work on ruby 1.8.7 --- lib/puppet/parser/functions/getvar.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/puppet/parser/functions') diff --git a/lib/puppet/parser/functions/getvar.rb b/lib/puppet/parser/functions/getvar.rb index aa6edbb..3af8d48 100644 --- a/lib/puppet/parser/functions/getvar.rb +++ b/lib/puppet/parser/functions/getvar.rb @@ -20,11 +20,13 @@ module Puppet::Parser::Functions end begin + result = nil catch(:undefined_variable) do - return self.lookupvar("#{args[0]}") + result = self.lookupvar("#{args[0]}") end - - nil # throw was caught + + # avoid relying on incosistent behaviour around ruby return values from catch + result rescue Puppet::ParseError # Eat the exception if strict_variables = true is set end -- cgit v1.2.3