Browse Source

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).
rdb 5 years ago
parent
commit
30bca7a119
1 changed files with 5 additions and 3 deletions
  1. 5 3
      dtool/src/dtoolutil/executionEnvironment.cxx

+ 5 - 3
dtool/src/dtoolutil/executionEnvironment.cxx

@@ -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
 }