> An interactive shell can be a login-shell or a non-login-shell.
A shell can be login and non-interactive.
This happens e.g when starting a session from a X session manager. Subsequently a terminal such as Xterm starts non-login interactive sessions, inherits stuff like env vars like PATH from the login shell, and is only concerned with setting up the additional interactive stuff.
Similarly doing ssh <host> <command> starts a non-interactive login shell.
> However, bash behaves like an interactive non-login shell in this case and reads `bashrc`.
IIRC nope: distros such as Debian often have bashrc source bash profile (or the other way around, I can't recall) which has me irate to no end+. They even have some TTY dependent stuff in profile which spits out some error in some cases when no TTY is allocated because heh not interactive.
+ I took great length to have my rc and profile properly separated because it's that much faster not to source the unneeded stuff (at the cost of having to logout to apply login stuff) https://github.com/lloeki/dotfiles
Interesting, is there a source for this? Genuinely interested, because the manpage leaves this part a bit vague:
A login shell is one whose first character of argument zero is a -, or
one started with the --login option.
(...)
Bash attempts to determine when it is being run with its standard input
connected to a network connection, as when executed by the historical
remote shell daemon, usually rshd, or the secure shell daemon sshd.
If bash determines it is being run non-interactively in this fashion, it
reads and executes commands from ~/.bashrc, if that file exists
and is readable.
Sadly, the manpage for sshd also doesn't mention how exactly the users shell is invoked. It does say however:
After this, the client either requests an interactive shell or
execution of a non-interactive command
...which I took to understand that the shell dows in fact run as an interactive shell.
> IIRC nope: distros such as Debian often have bashrc source bash profile
Well, these are distro dependent things. Since I am not on Debian, I am just refering to the manpage.
A shell can be login and non-interactive.
This happens e.g when starting a session from a X session manager. Subsequently a terminal such as Xterm starts non-login interactive sessions, inherits stuff like env vars like PATH from the login shell, and is only concerned with setting up the additional interactive stuff.
Similarly doing ssh <host> <command> starts a non-interactive login shell.
> However, bash behaves like an interactive non-login shell in this case and reads `bashrc`.
IIRC nope: distros such as Debian often have bashrc source bash profile (or the other way around, I can't recall) which has me irate to no end+. They even have some TTY dependent stuff in profile which spits out some error in some cases when no TTY is allocated because heh not interactive.
+ I took great length to have my rc and profile properly separated because it's that much faster not to source the unneeded stuff (at the cost of having to logout to apply login stuff) https://github.com/lloeki/dotfiles