4 Shell Builtin Commands
Builtin commands are contained within the shell itself. When the name of a builtin com- mand is used as the first word of a simple command (see Section 3.2.1 [Simple Commands], page 8), the shell executes the command directly, without invoking another program. Builtin commands are necessary to implement functionality impossible or inconvenient to obtain with separate utilities.
This section briefly describes the builtins which Bash inherits from the Bourne Shell, as well as the builtin commands which are unique to or have been extended in Bash.
Several builtin commands are described in other chapters: builtin commands which provide the Bash interface to the job control facilities (see Section 7.2 [Job Control Builtins], page 98), the directory stack (see Section 6.8.1 [Directory Stack Builtins], page 90), the command history (see Section 9.2 [Bash History Builtins], page 133), and the programmable completion facilities (see Section 8.7 [Programmable Completion Builtins], page 126).
Many of the builtins have been extended by posix or Bash.
Unless otherwise noted, each builtin command documented as accepting options pre- ceded by ‘-’ accepts ‘--’ to signify the end of the options. The :, true, false, and test builtins do not accept options and do not treat ‘--’ specially. The exit, logout, break, continue, let, and shift builtins accept and process arguments beginning with ‘-’ with- out requiring ‘--’. Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with ‘-’ as invalid options and require ‘--’ to prevent this interpretation.
4.1 Bourne Shell Builtins
The following shell builtin commands are inherited from the Bourne Shell. These commands are implemented as specified by the posix standard.
: (a colon)
: [arguments]
Do nothing beyond expanding arguments and performing redirections. The return status is zero.
. (a period)
. filename [arguments]
Read and execute commands from the filename argument in the current shell context. If filename does not contain a slash, the PATH variable is used to find filename. When Bash is not in posix mode, the current directory is searched if filename is not found in $PATH. If any arguments are supplied, they become the positional parameters when filename is executed. Otherwise the positional parameters are unchanged. The return status is the exit status of the last command executed, or zero if no commands are executed. If filename is not found, or cannot be read, the return status is non-zero. This builtin is equivalent to source. break