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')

Parameters:

  • key (String)

    The key to delete the value from

  • val (String)

    The value to delete for the key



115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/beaker/host/pswindows/exec.rb', line 115

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