Only /bin/bash has --rcfile, so name the script accordingly; On Mac /bin/sh is alias for /bin/bash, so we handle that as well

This commit is contained in:
Dmitry Trofimov
2016-10-19 19:27:46 +02:00
parent c1202b8d16
commit 3314382d6e
5 changed files with 9 additions and 10 deletions
@@ -241,7 +241,7 @@ class CommunityRepositoryModules {
javaFXPlugin("javaFX-CE"),
plugin("terminal") {
withResource("resources/.zshrc", "")
withResource("resources/jediterm-sh.in", "")
withResource("resources/jediterm-bash.in", "")
}
]
@@ -72,8 +72,8 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
private static String findRCFile(String shellName) {
if (shellName != null) {
if ("bash".equals(shellName)) {
shellName = "sh";
if ("sh".equals(shellName)) {
shellName = "bash";
}
try {
@@ -195,10 +195,9 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
String rcFilePath = findRCFile(shellName);
if (rcFilePath != null &&
shellIntegration) {
if (shellName.equals("bash") || shellName.equals("sh")) {
if (shellName.equals("bash") || (SystemInfo.isMac && shellName.equals("sh"))) {
addRcFileArgument(envs, command, result, rcFilePath, "--rcfile");
}
else if (shellName.equals("zsh")) {
@@ -43,10 +43,10 @@ public class TerminalShellCommandTest extends TestCase {
}
public void testAddRcConfig() {
hasRcConfig("bash -i", "jediterm-sh.in", Maps.newHashMap());
hasRcConfig("sh --login", "jediterm-sh.in", Maps.newHashMap());
hasRcConfig("bash -i", "jediterm-bash.in", Maps.newHashMap());
hasRcConfig("sh --login", "jediterm-bash.in", Maps.newHashMap());
Map<String, String> envs = Maps.newHashMap();
hasRcConfig("sh --rcfile ~/.bashrc", "jediterm-sh.in", envs);
hasRcConfig("sh --rcfile ~/.bashrc", "jediterm-bash.in", envs);
assertEquals("~/.bashrc", envs.get("JEDITERM_SOURCE"));
}
@@ -45,8 +45,8 @@ class PyVirtualEnvTerminalCustomizer : LocalTerminalCustomizer() {
val shellPath = command[0]
val shellName = File(shellPath).name
if (shellName == "bash" || shellName == "sh") {
//for bash and sh we pass activate script to jediterm shell integration (see jediterm-sh.in) to source it there
if (shellName == "bash" || (SystemInfo.isMac && shellName == "sh")) {
//for bash we pass activate script to jediterm shell integration (see jediterm-bash.in) to source it there
findActivateScript(path, shellPath)?.let { activate -> envs.put("JEDITERM_SOURCE", activate) }
}
else {