diff options
Diffstat (limited to 'lib/puppet/util/execution.rb')
-rw-r--r-- | lib/puppet/util/execution.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/puppet/util/execution.rb b/lib/puppet/util/execution.rb index dd820f856..69f4f2c15 100644 --- a/lib/puppet/util/execution.rb +++ b/lib/puppet/util/execution.rb @@ -4,16 +4,15 @@ module Puppet::Util::Execution # Run some code with a specific environment. Resets the environment back to # what it was at the end of the code. def withenv(hash) - oldvals = {} + saved = ENV.to_hash hash.each do |name, val| - name = name.to_s - oldvals[name] = ENV[name] - ENV[name] = val + ENV[name.to_s] = val end yield ensure - oldvals.each do |name, val| + ENV.clear + saved.each do |name, val| ENV[name] = val end end |