lib/beaker/host/unix/exec.rb
def delete_env_var key, val
    key = key.to_s
    env_file = self[:ssh_env_file]
    val = Regexp.escape(val).gsub('/', '\/').gsub(';', '\;')
    #if the key only has that single value remove the entire line
    exec(Beaker::SedCommand.new(self['platform'], "/#{key}=#{val}$/d", env_file))
    #value in middle of list
    exec(Beaker::SedCommand.new(self['platform'], "s/#{key}=\\(.*\\)[;:]#{val}/#{key}=\\1/", env_file))
    #value in start of list
    exec(Beaker::SedCommand.new(self['platform'], "s/#{key}=#{val}[;:]/#{key}=/", env_file))
    #update the profile.d to current state
    #match it to the contents of ssh_env_file
    mirror_env_to_profile_d(env_file)
  end
#Delete the provided key/val from the current ssh environment
#@param [String] key The key to delete the value from
#@param [String] val The value to delete for the key
#@example
#  host.delete_env_var('PATH', '/usr/bin:PATH')
Delete the provided key/val from the current ssh environment
Delete the provided key / val from the current ssh environment
def delete_env_var key, val
    key = key.to_s
    env_file = self[:ssh_env_file]
    val = Regexp.escape(val).gsub('/', '\/').gsub(';', '\;')
    exec(Beaker::SedCommand.new(self['platform'], "/#{key}=#{val}$/d", env_file))
    exec(Beaker::SedCommand.new(self['platform'], "s/#{key}=\\(.*\\)[;:]#{val}/#{key}=\\1/", env_file))
    exec(Beaker::SedCommand.new(self['platform'], "s/#{key}=#{val}[;:]/#{key}=/", env_file))
    mirror_env_to_profile_d(env_file)
  end
def delete_env_var key , val key = key . to_s env_file = self [ :ssh_env_file ] val = Regexp . escape ( val ) . gsub ( '/' , '\/' ) . gsub ( ';' , '\;' ) exec ( Beaker :: SedCommand . new ( self [ 'platform' ] , "/#{key}=#{val}$/d" , env_file ) ) exec ( Beaker :: SedCommand . new ( self [ 'platform' ] , "s/#{key}=\\(.*\\)[;:]#{val}/#{key}=\\1/" , env_file ) ) exec ( Beaker :: SedCommand . new ( self [ 'platform' ] , "s/#{key}=#{val}[;:]/#{key}=/" , env_file ) ) mirror_env_to_profile_d ( env_file ) end
Delete the provided key/val from the current ssh environment
Delete the provided key / val from the current ssh environment
#if the key only has that single value remove the entire line #value in middle of list #value in start of list #update the profile.d to current state #match it to the contents of ssh_env_file
key
val
val The value to delete for the key
val The value to delete for the key
example
None