better naming as SHELL environment is CONSOLE
[idea/community.git] / platform / lang-impl / src / com / intellij / execution / configuration / EnvironmentVariablesData.java
index 1f4a7b9083ec12cca858c349c6eaa4657144ba08..b52e1046487c539eeb755a6b5503ff1abc164708 100644 (file)
@@ -16,6 +16,7 @@
 package com.intellij.execution.configuration;
 
 import com.google.common.collect.ImmutableMap;
+import com.intellij.execution.configurations.GeneralCommandLine;
 import com.intellij.util.containers.ContainerUtil;
 import org.jdom.Element;
 import org.jetbrains.annotations.NonNls;
@@ -83,7 +84,7 @@ public class EnvironmentVariablesData {
       return DEFAULT;
     }
     Map<String, String> envs = ImmutableMap.of();
-    String passParentEnvsStr = element.getAttributeValue(PASS_PARENT_ENVS);
+    String passParentEnvsStr = envsElement.getAttributeValue(PASS_PARENT_ENVS);
     boolean passParentEnvs = passParentEnvsStr == null || Boolean.parseBoolean(passParentEnvsStr);
     for (Element envElement : envsElement.getChildren(ENV)) {
       String envName = envElement.getAttributeValue(NAME);
@@ -114,6 +115,17 @@ public class EnvironmentVariablesData {
     parent.addContent(envsElement);
   }
 
+  public void configureCommandLine(@NotNull GeneralCommandLine commandLine, boolean consoleParentEnvs) {
+    if (myPassParentEnvs) {
+      commandLine.withParentEnvironmentType(consoleParentEnvs ? GeneralCommandLine.ParentEnvironmentType.CONSOLE
+                                                              : GeneralCommandLine.ParentEnvironmentType.SYSTEM);
+    }
+    else {
+      commandLine.withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.NONE);
+    }
+    commandLine.withEnvironment(myEnvs);
+  }
+
   /**
    * @param envs Map instance containing user-defined environment variables
    *             (iteration order should be reliable user-specified, like {@link LinkedHashMap} or {@link ImmutableMap})