So the bash man pages explain what login and interactive shells are:
A login shell is one whose first character of argument zero is a -, or one started with the --login option.
An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.
I think this means we can have 4 different types of shells:
- Interactive login shells,
- Non-interactive login shells,
- Interactive non-login shells,
- Non-interactive non-login shells
But why do we have interactive/non-interactive and login/non-login shells in the first place? Why the variety? What would we lose if we only had one type of shell?
Also when trying to determine if I am in a login shell by running echo $-
, it outputs:
himBH
Some of these flags are explained here, but h
, H
, and m
are not explained. Is there a place that describes all these flags?