diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/ProcessFactory.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/ProcessFactory.java index 5fd5dce9ac1..addd040267a 100644 --- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/ProcessFactory.java +++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/spawner/ProcessFactory.java @@ -62,9 +62,17 @@ private static TreeMap newEmptyEnvironment() { return environment; } - private static TreeMap envpToEnvMap(String[] envp) { + private static TreeMap getDefaultEnvironment() { TreeMap environment = newEmptyEnvironment(); + Map env = new ProcessBuilder().environment(); + environment.putAll(env); + return environment; + } + + private static TreeMap envpToEnvMap(String[] envp) { + TreeMap environment; if (envp != null) { + environment = newEmptyEnvironment(); for (String envstring : envp) { int eqlsign = envstring.indexOf('='); if (eqlsign != -1) { @@ -73,17 +81,12 @@ private static TreeMap envpToEnvMap(String[] envp) { // Silently ignore envstrings lacking the required `='. } } + } else { + environment = getDefaultEnvironment(); } return environment; } - private static TreeMap getDefaultEnvironment() { - TreeMap environment = newEmptyEnvironment(); - Map env = new ProcessBuilder().environment(); - environment.putAll(env); - return environment; - } - private static void appendEnvMapComparison(StringBuilder sb, TreeMap environmentA, TreeMap environmentB) { TreeMap environmentC = newEmptyEnvironment();