Contents
Is there a non-interactive login shell in Bash?
non-interactive non-login shell:Run a script. All scripts run in their own subshell and this shell is not interactive. It only opens to execute the script and closes immediately once the script is finished. non-interactive login shell:This is extremely rare, and you’re unlikey to encounter it.
How to run bashrc in a non-interactive shell?
In general, $HOME/.bashrc is executed for non-interactive login shells, but no script can be guaranteed to run for a non-interactive non-login shell. You can force it by setting (and exporting!) BASH_ENV from a parent shell to the name of a script which you want to execute when a non-interactive shell is started.
How to start a non-interactive shell on SSH?
If the stdin of the ssh is not a tty, it starts a non-interactive shell. This is why echo command | ssh server will launch a non-interactive login shell. You can also start one with bash -l -c command.
How does the login process in Bash work?
The login process tells the shell to behave as a login shell with a convention: passing argument 0, which is normally the name of the shell executable, with a “ – ” character prepended Reads commands from user input on a tty. Among other things, such a shell reads startup files on activation, displays a prompt, and enables job control by default.
What makes a shell a non-interactive shell?
A shell running a script is always a non-interactive shell. Simply put: Interactive shell require user input, while non-interactive shell are run by scripts and don’t require user inputs.
What’s the difference between a script and a login shell?
A shell running a script is always a non-interactive shell. Simply put: Interactive shell require user input, while non-interactive shell are run by scripts and don’t require user inputs. One category of shell (Non-interactive, login shell with hBc options) is missing in the accepted answer.