echo $0 -bashSince "-bash" has the first character is "-", this is a login shell. When a login shell exits, bash reads and executes commands from the file [~/.bash_logout], if it exists.
The interactive shell is used when you open a terminal session.
You can determine if the shell is interactive if the variable "-" includes an "i".
echo $- himBHAs "himBH" includes the character "i", this is an interactive shell.
Typically the environment variable PS1 (the primary prompt string) is set when using an interactive shell.
A interactive login shell is exited by 'logout'. Typing 'exit' in a login shell will run 'logout'.
To prevent bash from running the interactive login shell scripts when it is invoked as an interactive login shell you can use the option:
bash --noprofile
When you run a shell script, a new non-interactive shell is launched to execute the script. The new shell is a non-interactive shell.
You can determine if the shell is interactive if the variable "-" does NOT includes an "i".
echo $- hB
A non-interactive shell is exited by 'exit'
To prevent bash from running the non-interactive shell scripts when it is invoked as a interactive login shell you can use the:
bash --norc
Interactive shells also read and execute .bashrc.
Often you will see that [etc/profile] sources .bashrc - thus all settings made in .bashrc will also take effect in a login shell regardless of if it is interactive or non-interactive.
The order of execution of the initialization scripts for a shell is dependent on if the shell is interactive or non-interactive and not related to if it is a login script or not.
When bash is invoked as an interactive login shell it reads and executes commands from the [/etc/profile]. Then Bash will then try in order to execute ONLY the first file exists and is readable of the following:
If one of these files is found but can not be read, it will error. There is no error if any are NOT found.This same process is followed when a non-interactive login shell is invoked with the --login option.
This implies none of the following:
ssh remotesystem ../bin/true > test.datThis command-line should create a file called test.dat with nothing in it. If test.dat is not of zero length then your shell is not clean. Look at the contents of test.dat to see what was sent. Look at all the shell initialization files on remotesystem to try and find the problem.