A login shell executes:
A login shell is a shell:
- whose first character of argument zero ($0) is a -
- or started with the –login or -l option.
When bash is invoked as:
it reads and executes commands from the following files in this order:
- ~/.bash_profile, # only read by bash
- ~/.bash_login, # only read by bash
- and ~/.profile,
The file must exists and be readable.
The –noprofile option may be used when the shell is started to inhibit this behavior.
When a login shell exits, bash reads and executes commands from the files:
if the files exists.
In a script, you can test if the shell is a login shell with this predicate.
argv == '-'