dtoolutil: fix ExecutionEnvironment::has_environment_variable() for shadowed var

Fixes MAIN_DIR being set more than once (which seems to avoid a compiler bug in an opt4 build).
This commit is contained in:
rdb 2020-12-22 16:22:45 +01:00
parent 8f9ca34eec
commit 30bca7a119

View File

@ -217,9 +217,11 @@ get_cwd() {
*/
bool ExecutionEnvironment::
ns_has_environment_variable(const string &var) const {
#ifdef PREREAD_ENVIRONMENT
return _variables.count(var) != 0;
#else
if (_variables.count(var) != 0) {
return true;
}
#ifndef PREREAD_ENVIRONMENT
return getenv(var.c_str()) != nullptr;
#endif
}