38 char const* old = std::getenv(name);
43 if (value !=
nullptr) {
44 setenv(name, value, 1);
52 setenv(name_.c_str(), old_value_.c_str(), 1);
54 unsetenv(name_.c_str());
63 std::string old_value_;
64 bool had_value_{
false};
RAII guard that saves, optionally modifies, and restores an environment variable.
ScopedEnvVar(char const *name, char const *value)
Construct the guard, saving and optionally replacing the variable.