mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
getting environment variable for remote case fixup
This commit is contained in:
@@ -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) {
|
||||
|
||||
+1
-2
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user