Use shell options only if applicable.

This commit is contained in:
Dmitry Trofimov
2013-09-24 01:51:35 +02:00
parent b4f21b9d57
commit 00a127bbdd
@@ -40,22 +40,35 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
myDefaultCharset = Charset.forName("UTF-8");
String shellPath = TerminalOptionsProvider.getInstance().getShellPath();
if (SystemInfo.isUnix) {
File rcFile = findRCFile();
if (rcFile != null) {
String shellName = getShellName(shellPath);
if (rcFile != null && (shellName.equals("bash") || shellName.equals("sh"))) {
myCommand = new String[]{shellPath, "--rcfile", rcFile.getAbsolutePath(), "-i"};
}
else {
else if (hasLoginArgument(shellName)) {
myCommand = new String[]{shellPath, "--login"};
}
else {
myCommand = shellPath.split(" ");
}
}
else {
myCommand = new String[]{shellPath};
}
}
private static boolean hasLoginArgument(String name) {
return name.equals("bash") || name.equals("sh") || name.equals("zsh");
}
private static String getShellName(String path) {
return new File(path).getName();
}
private static File findRCFile() {
try {
final String folder = PtyUtil.getJarFolder();