getting environment variable for remote case fixup

This commit is contained in:
Viuginov Nickolay
2018-05-16 23:37:30 +03:00
parent 7d215f05e1
commit c51e00f3fc
3 changed files with 10 additions and 5 deletions
@@ -273,12 +273,11 @@ public class EnvironmentUtil {
}
@NotNull
public static Map<String, String> parseEnv(String text) throws Exception {
public static Map<String, String> parseEnv(String... lines) throws Exception {
Set<String> toIgnore = new HashSet<String>(Arrays.asList("_", "PWD", "SHLVL", DISABLE_OMZ_AUTO_UPDATE, INTELLIJ_ENVIRONMENT_READER));
Map<String, String> env = System.getenv();
Map<String, String> newEnv = new HashMap<String, String>();
String[] lines = text.split("\0");
for (String line : lines) {
int pos = line.indexOf('=');
if (pos <= 0) {
@@ -297,6 +296,13 @@ public class EnvironmentUtil {
return newEnv;
}
@NotNull
private static Map<String, String> parseEnv(String text) throws Exception {
String[] lines = text.split("\0");
return parseEnv(lines);
}
private static int waitAndTerminateAfter(@NotNull Process process, int timeoutMillis) {
Integer exitCode = waitFor(process, timeoutMillis);
if (exitCode != null) {
@@ -45,8 +45,7 @@ public abstract class AttachOSHandler {
}
if(myEnvironment == null) {
final String envString = myHost.getProcessOutput(ENV_COMMAND_LINE).getStdout();
myEnvironment = EnvironmentUtil.parseEnv(envString);
myEnvironment = EnvironmentUtil.parseEnv(myHost.getProcessOutput(ENV_COMMAND_LINE).getStdout().split("\n"));
}
return myEnvironment.get(name);
@@ -85,7 +85,7 @@ public abstract class UnixAttachOSHandler extends AttachOSHandler {
commands.add("-c");
commands.add(String.format(GET_PROCESS_USER, pid));
try {
return myHost.getProcessOutput(new GeneralCommandLine(commands)).getStdout().equals(getenv("USER"));
return myHost.getProcessOutput(new GeneralCommandLine(commands)).getStdout().trim().equals(getenv("USER"));
}
catch (Exception e) {
LOGGER.warn("Failed to compare users", e);