config: update environment if cfg changes live (#11508)

This commit is contained in:
Vaxry 2025-08-29 11:16:11 +02:00 committed by GitHub
parent a209f9911c
commit 790e544689
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3107,14 +3107,18 @@ std::optional<std::string> CConfigManager::handleSource(const std::string& comma
}
std::optional<std::string> CConfigManager::handleEnv(const std::string& command, const std::string& value) {
if (!m_isFirstLaunch)
return {};
const auto ARGS = CVarList(value, 2);
if (ARGS[0].empty())
return "env empty";
if (!m_isFirstLaunch) {
// check if env changed at all. If it didn't, ignore. If it did, update it.
const auto* ENV = getenv(ARGS[0].c_str());
if (ENV && ENV == ARGS[1])
return {}; // env hasn't changed
}
setenv(ARGS[0].c_str(), ARGS[1].c_str(), 1);
if (command.back() == 'd') {