Interactive Shell Behavior
When the shell is running interactively, it changes its behavior in several ways.
- Bash reads and executes startup files as described in Bash Startup Files.
- Job Control (see Job Control) is enabled by default. When job control is in effect, Bash ignores the keyboard-generated job control signals
SIGTTIN,SIGTTOU, andSIGTSTP. - Bash executes the values of the set elements of the
PROMPT_COMMANDarray variable as commands before printing the primary prompt,$PS1(see Bash Variables). - Bash expands and displays
PS1before reading the first line of a command, and expands and displaysPS2before reading the second and subsequent lines of a multi-line command. Bash expands and displaysPS0after it reads a command but before executing it. See Controlling the Prompt, for a complete list of prompt string escape sequences. - Bash uses Readline (see Command Line Editing) to read commands from the user’s terminal.
- Bash inspects the value of the
ignoreeofoption toset -oinstead of exiting immediately when it receives anEOFon its standard input when reading a command (see The Set Builtin). - Bash enables Command history (see Bash History Facilities) and history expansion (see History Expansion) by default. When a shell with history enabled exits, Bash saves the command history to the file named by
$HISTFILE. - Alias expansion (see Aliases) is performed by default.
- In the absence of any traps, Bash ignores
SIGTERM(see Signals). - In the absence of any traps,
SIGINTis caught and handled (see Signals).SIGINTwill interrupt some shell builtins. - An interactive login shell sends a
SIGHUPto all jobs on exit if thehuponexitshell option has been enabled (see Signals). - The -n option has no effect, whether at invocation or when using ‘set -n’ (see The Set Builtin).
- Bash will check for mail periodically, depending on the values of the
MAIL,MAILPATH, andMAILCHECKshell variables (see Bash Variables). - The shell will not exit on expansion errors due to references to unbound shell variables after ‘set -u’ has been enabled (see The Set Builtin).
- The shell will not exit on expansion errors caused by var being unset or null in
${var:?word}expansions (see Shell Parameter Expansion). - Redirection errors encountered by shell builtins will not cause the shell to exit.
- When running in POSIX mode, a special builtin returning an error status will not cause the shell to exit (see Bash and POSIX).
- A failed
execwill not cause the shell to exit (see Bourne Shell Builtins). - Parser syntax errors will not cause the shell to exit.
- If the
cdspellshell option is enabled, the shell will attempt simple spelling correction for directory arguments to thecdbuiltin (see the description of thecdspelloption to theshoptbuiltin in The Shopt Builtin). Thecdspelloption is only effective in interactive shells. - The shell will check the value of the
TMOUTvariable and exit if a command is not read within the specified number of seconds after printing$PS1(see Bash Variables).
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
Licensed under the GNU Free Documentation License.
https://www.gnu.org/software/bash/manual/html_node/Interactive-Shell-Behavior.html