Method: PSWindows::Exec#delete_env_var

Defined in:
lib/beaker/host/pswindows/exec.rb

#delete_env_var(key, val) ⇒ Object

Delete the provided key/val from the current ssh environment

Examples:

host.delete_env_var('PATH', '/usr/bin:PATH')


105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/beaker/host/pswindows/exec.rb', line 105

def delete_env_var key, val
  key = key.to_s.upcase
  #get the current value of the key
  cur_val = subbed_val = get_env_var(key, true)
  subbed_val = (cur_val.split(';') - [val.gsub(/'|"/, '')]).join(';')
  if subbed_val != cur_val
    #remove the current key value
    self.clear_env_var(key)
    #set to the truncated value
    self.add_env_var(key, subbed_val)
  end
end