--- /dev/null
+#!/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()
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());
}
}
@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();