#include <ArmarXCore/core/system/EnvExpander.h>
|
| void | apply (const std::string &input, bool expandExisting=true) |
| | Parse and apply the comma-separated assignment list to the internal environment env_ and to the process environment via setenv.
|
| |
| void | applyOperation (const std::string &name, Operation op, const std::string &val) |
| |
| | EnvExpander () |
| | Construct an EnvExpander initialized with the current process environment.
|
| |
|
| static std::string | expand (const std::string &input) |
| | Return the expanded form of the comma-separated assignment list without modifying the process environment.
|
| |
| static std::string | expandVariables (const std::string &value) |
| |
| static std::vector< std::string > | splitAssignments (const std::string &input) |
| |
| static std::tuple< std::string, Operation, std::string > | splitOperation (const std::string &assignment) |
| |
|
| boost::process::environment | env_ |
| |
Definition at line 37 of file EnvExpander.h.
◆ Operation
| Enumerator |
|---|
| Replace | |
| Append | |
| Prepend | |
Definition at line 79 of file EnvExpander.h.
◆ EnvExpander()
Construct an EnvExpander initialized with the current process environment.
The instance keeps a working copy of the environment (stored in env_) which apply() will update when assignments are applied. This allows expansions to optionally see earlier changes.
Definition at line 109 of file EnvExpander.cpp.
◆ apply()
| void apply |
( |
const std::string & | input, |
|
|
bool | expandExisting = true ) |
Parse and apply the comma-separated assignment list to the internal environment env_ and to the process environment via setenv.
The input format is a comma-separated list of assignments. Each assignment may be a replace (NAME=val), append (NAME+=val) or prepend (NAME=+val). Whitespace around entries is ignored. Values may include environment variable references (e.g. $HOME or ${HOME}), which will be expanded before applying the assignment.
Current implementation notes: apply uses expand to expand the RHS values and then applies the parsed operations. The working copy env_ is updated so later calls can observe previous changes.
Definition at line 114 of file EnvExpander.cpp.
◆ applyOperation()
| void applyOperation |
( |
const std::string & | name, |
|
|
Operation | op, |
|
|
const std::string & | val ) |
◆ expand()
| std::string expand |
( |
const std::string & | input | ) |
|
|
static |
Return the expanded form of the comma-separated assignment list without modifying the process environment.
This mirrors the expansions performed by apply.
Special behavior: append and prepend operations are returned as explicit replacement assignments combining the existing environment value and the expanded RHS. For example, if the current value of PATH is "/usr/bin" and the input contains "PATH+=/opt/bin", this method returns "PATH=/usr/bin:/opt/bin" (or "PATH=/opt/bin" if PATH was not previously set).
Definition at line 150 of file EnvExpander.cpp.
◆ expandVariables()
| std::string expandVariables |
( |
const std::string & | value | ) |
|
|
static |
◆ splitAssignments()
| std::vector< std::string > splitAssignments |
( |
const std::string & | input | ) |
|
|
static |
◆ splitOperation()
| std::tuple< std::string, EnvExpander::Operation, std::string > splitOperation |
( |
const std::string & | assignment | ) |
|
|
static |
◆ env_
| boost::process::environment env_ |
The documentation for this class was generated from the following files: