Fix possible exception

This commit is contained in:
Dmitry Trofimov
2017-04-25 20:33:01 +02:00
parent 7e3e74090b
commit e0abfeeee9
@@ -17,7 +17,6 @@ package org.jetbrains.plugins.terminal;
import com.google.common.collect.Lists;
import com.intellij.execution.TaskExecutor;
import com.intellij.execution.configurations.EncodingEnvironmentUtil;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
@@ -71,8 +70,13 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
return name.equals("bash") || name.equals("sh") || name.equals("zsh");
}
private static String getShellName(String path) {
return new File(path).getName();
private static String getShellName(@Nullable String path) {
if (path == null) {
return null;
}
else {
return new File(path).getName();
}
}
private static String findRCFile(String shellName) {
@@ -181,9 +185,8 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
if (SystemInfo.isUnix) {
List<String> command = Lists.newArrayList(shellPath.split(" "));
String shellCommand = command.get(0);
String shellName = command.size() > 0 ? getShellName(shellCommand) : null;
String shellCommand = command.size() > 0 ? command.get(0) : null;
String shellName = getShellName(shellCommand);
if (shellName != null) {
command.remove(0);