Merge remote-tracking branch 'origin/master'
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 28 Sep 2016 17:39:21 +0000 (19:39 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 28 Sep 2016 17:39:21 +0000 (19:39 +0200)
bin/linux/printenv.py [new file with mode: 0755]
platform/util/src/com/intellij/util/EnvironmentUtil.java
plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java

diff --git a/bin/linux/printenv.py b/bin/linux/printenv.py
new file mode 100755 (executable)
index 0000000..a60959c
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+# Dumps environment variables into specified file.
+# Format: zero-separated "name=value" pairs in platform encoding.
+
+import os
+import sys
+
+if len(sys.argv) != 2:
+    raise Exception('Exactly one argument expected')
+
+f = open(sys.argv[1], 'wb')
+try:
+    for key, value in os.environ.items():
+        s = '%s=%s\0' % (key, value)
+        f.write(s.encode('utf-8'))
+finally:
+    f.close()
index 1d6428dadfd6a49fbfa808f6606063fc5d48a18f..dc31d03bd7c49e659355f21debe8c33e4b314c5c 100644 (file)
@@ -161,10 +161,11 @@ public class EnvironmentUtil {
   public static class ShellEnvReader {
 
     public Map<String, String> readShellEnv() throws Exception {
+      String os = SystemInfo.isLinux ? "linux" : "mac";
       File reader = FileUtil.findFirstThatExist(
         PathManager.getBinPath() + "/printenv.py",
-        PathManager.getHomePath() + "/community/bin/mac/printenv.py",
-        PathManager.getHomePath() + "/bin/mac/printenv.py");
+        PathManager.getHomePath() + "/community/bin/" + os + "/printenv.py",
+        PathManager.getHomePath() + "/bin/" + os + "/printenv.py");
       if (reader == null) {
         throw new Exception("bin:" + PathManager.getBinPath());
       }
@@ -185,7 +186,8 @@ public class EnvironmentUtil {
     }
 
     @NotNull
-    protected static Map<String, String> runProcessAndReadEnvs(@NotNull List<String> command, @NotNull File envFile, String lineSeparator) throws Exception {
+    protected static Map<String, String> runProcessAndReadEnvs(@NotNull List<String> command, @NotNull File envFile, String lineSeparator)
+      throws Exception {
       ProcessBuilder builder = new ProcessBuilder(command).redirectErrorStream(true);
       builder.environment().put(DISABLE_OMZ_AUTO_UPDATE, "true");
       Process process = builder.start();
index f96e3468aa98c288cfa9f9b356ec9d95670a2a68..a4c6f5846b1e8da41ed92029469a55c7d8fb0d23 100644 (file)
@@ -164,13 +164,14 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
     if (SystemInfo.isUnix) {
       List<String> command = Lists.newArrayList(shellPath.split(" "));
 
-      String shellName = command.size() > 0 ? getShellName(command.get(0)) : null;
+      String shellCommand = command.get(0);
+      String shellName = command.size() > 0 ? getShellName(shellCommand) : null;
 
 
       if (shellName != null) {
         command.remove(0);
 
-        List<String> result = Lists.newArrayList(shellName);
+        List<String> result = Lists.newArrayList(shellCommand);
 
         String rcFilePath = findRCFile(shellName);