Fix login shell detection in shell integration scripts (IDEA-164435)
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Fri, 25 Nov 2016 14:36:12 +0000 (15:36 +0100)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Fri, 25 Nov 2016 14:40:35 +0000 (15:40 +0100)
plugins/terminal/resources/jediterm-bash.in
plugins/terminal/src/org/jetbrains/plugins/terminal/LocalTerminalDirectRunner.java

index 84f9a799296b744919aadf064637168b04717522..74dd6fdff375a9141b0a5ab546b7ead0d663d61e 100644 (file)
@@ -31,7 +31,7 @@ function load_interactive_configs {
   fi
 }
 
-if [ `shopt -q login_shell` ]; then
+if [ -n $LOGIN_SHELL ]; then
   load_login_configs
 fi
 
index 11bf1ad8ac9563766056889ee4276ec62cca0a2b..ed90427205f4b89f036bd40ec8637a0b1cc5942c 100644 (file)
@@ -228,6 +228,10 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
           result.add("-i");
         }
 
+        if (isLogin(command)) {
+          envs.put("LOGIN_SHELL", "1");
+        }
+
         result.addAll(command);
         return ArrayUtil.toStringArray(result);
       }
@@ -257,7 +261,11 @@ public class LocalTerminalDirectRunner extends AbstractTerminalRunner<PtyProcess
   }
 
   private static boolean loginOrInteractive(List<String> command) {
-    return command.contains("-i") || command.contains("--login") || command.contains("-l");
+    return command.contains("-i") || isLogin(command);
+  }
+
+  private static boolean isLogin(List<String> command) {
+    return command.contains("--login") || command.contains("-l");
   }
 
   private static class PtyProcessHandler extends ProcessHandler implements TaskExecutor {