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



135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/beaker/host/pswindows/exec.rb', line 135

def delete_env_var key, val
  key = key.to_s.upcase
  # get the current value of the key
  cur_val = get_env_var(key, true)
  subbed_val = (cur_val.split(';') - [val.gsub(/'|"/, '')]).join(';')
  return unless 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