Read correct configs for non-login interactive shell (IDEA-114126)
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 31 Aug 2016 18:13:11 +0000 (20:13 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Wed, 31 Aug 2016 18:13:11 +0000 (20:13 +0200)
plugins/terminal/resources/jediterm-sh.in

index ccc2a702bd208501ed56d7edc39b53aebb9fa577..e77f164d5b83c2aa169ef4d7989a6c5a2bd5fb4a 100644 (file)
@@ -1,33 +1,42 @@
 #!/bin/bash
 
-#       When bash is invoked as an interactive login shell, or as a  non-interac-
-#       tive  shell with the --login option, it first reads and executes commands
-#       from the file /etc/profile, if that  file  exists.   After  reading  that
-#       file,  it  looks  for  ~/.bash_profile, ~/.bash_login, and ~/.profile, in
-#       that order, and reads and executes  commands  from  the  first  one  that
-#       exists  and  is  readable.  
-
-if [ -f /etc/profile ];
-then
-   source /etc/profile
-fi
+function load_login_configs {
+  #       When bash is invoked as an interactive login shell, or as a  non-interac-
+  #       tive  shell with the --login option, it first reads and executes commands
+  #       from the file /etc/profile, if that  file  exists.   After  reading  that
+  #       file,  it  looks  for  ~/.bash_profile, ~/.bash_login, and ~/.profile, in
+  #       that order, and reads and executes  commands  from  the  first  one  that
+  #       exists  and  is  readable.
+
+  if [ -f /etc/profile ]; then
+     source /etc/profile
+  fi
+
+  if [ -f ~/.bash_profile ]; then
+     source ~/.bash_profile
+  else
+     if [ -f ~/.bash_login ]; then
+        source ~/.bash_login
+     else
+        if [ -f ~/.profile ]; then
+           source ~/.profile
+        fi
+     fi
+  fi
+}
 
-if [ -f ~/.bash_profile ];
-then
-   source ~/.bash_profile
+function load_interactive_configs {
+  if [ -f ~/.bash_profile ]; then
+       source ~/.bashrc
+  fi
+}
+
+if [ `shopt -q login_shell` ]; then
+  load_login_configs
 else
-   if [ -f ~/.bash_login ]
-   then
-      source ~/.bash_login
-   else
-      if [ -f ~/.profile ]
-      then
-         source ~/.profile
-      fi
-   fi
+  load_interactive_configs
 fi
 
-
 # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
 bind '"\e\e[C":forward-word'
 bind '"\e\e[D": backward-word'