diff --git a/lib/facter/custom_facts/core/execution/base.rb b/lib/facter/custom_facts/core/execution/base.rb index 6d4a5d8cf9..a498208c68 100644 --- a/lib/facter/custom_facts/core/execution/base.rb +++ b/lib/facter/custom_facts/core/execution/base.rb @@ -25,8 +25,8 @@ def with_env(values) # set the new (temporary) value for the environment variable ENV[var] = value end - # execute the caller's block, capture the return value - rv = yield + # execute the caller's block, returning its value + yield # use an ensure block to make absolutely sure we restore the variables ensure # restore the old values @@ -38,8 +38,6 @@ def with_env(values) ENV.delete(var) end end - # return the captured return value - rv end def execute(command, options = {})