File envFile = FileUtil.createTempFile("intellij-shell-env.", ".tmp", false);
try {
List<String> command = getShellProcessCommand();
- command.add("-c");
- command.add("'" + reader.getAbsolutePath() + "' '" + envFile.getAbsolutePath() + "'");
+
+ int idx = command.indexOf("-c");
+ if (idx>=0) {
+ // if there is already a command append command to the end
+ command.set(idx + 1, command.get(idx+1) + ";" + "'" + reader.getAbsolutePath() + "' '" + envFile.getAbsolutePath() + "'");
+ } else {
+ command.add("-c");
+ command.add("'" + reader.getAbsolutePath() + "' '" + envFile.getAbsolutePath() + "'");
+ }
LOG.info("loading shell env: " + StringUtil.join(command, " "));
throw Exception("shell:" + shellPath)
}
- return if (activate != null) mutableListOf(shellPath, "--rcfile", activate, "-i")
+ return if (activate != null)
+ if (File(shellPath).name == "sh") {
+ mutableListOf(shellPath, "-i", "-c", "source '$activate'")
+ } else {
+ mutableListOf(shellPath, "--rcfile", activate, "-i")
+ }
else super.getShellProcessCommand()
}