Sha256: 6c24bd564e37ebbabe7a31c4deec6d40aaf84931e40a5567e501e5b371b8e302

Contents?: true

Size: 413 Bytes

Versions: 7

Compression:

Stored size: 413 Bytes

Contents

module Puppet::Util::Execution
  module_function

  # 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 = {}
    hash.each do |name, val|
      name = name.to_s
      oldvals[name] = ENV[name]
      ENV[name] = val
    end

    yield
  ensure
    oldvals.each do |name, val|
      ENV[name] = val
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
puppet-2.6.6 lib/puppet/util/execution.rb
puppet-2.6.5 lib/puppet/util/execution.rb
puppet-2.6.4 lib/puppet/util/execution.rb
puppet-2.6.3 lib/puppet/util/execution.rb
puppet-2.6.2 lib/puppet/util/execution.rb
puppet-2.6.1 lib/puppet/util/execution.rb
puppet-2.6.0 lib/puppet/util/execution.rb