Class: Metasploit::Yard::Aruba::RvmEnv::Prepend
- Defined in:
- lib/metasploit/yard/aruba/rvm_env/prepend.rb
Overview
Recognizes export
s that are actually prepending values to the pre-existing value as is the case with PATH
.
Constant Summary collapse
- REGEXP =
Matches line with format
export <name>=<quote><value>$<name><quote>
.<value>
will contain trailingFile::PATH_SEPARATOR
, so it can be directly prepended to the current value of<name>
to get the value to set the environment variable. /\Aexport (?<name>\S+?)(\s+;\s+\k<name>)?=(?<quote>"|')(?<value>.*?#{File::PATH_SEPARATOR})\$\k<name>\k<quote>\Z/
Instance Attribute Summary
Attributes inherited from Export
Attributes inherited from Variable
Instance Method Summary collapse
-
#change(options = {}) ⇒ Object
Replaces
:from
value with this variable's value.
Methods inherited from Export
Methods inherited from Variable
Constructor Details
This class inherits a constructor from Metasploit::Yard::Aruba::RvmEnv::Export
Instance Method Details
#change(options = {}) ⇒ Object
Replaces :from
value with
this variable's value.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/metasploit/yard/aruba/rvm_env/prepend.rb', line 18 def change(={}) .assert_valid_keys(:from, :world) from = .fetch(:from) world = .fetch(:world) from_directories = from.value.split(File::PATH_SEPARATOR) to_directories = value.split(File::PATH_SEPARATOR) path = ENV[name] to_directories.zip(from_directories) do |to_directory, from_directory| path = path.gsub(from_directory, to_directory) end world.set_env(name, path) end |