-->

Previous | Table of Contents | Next

Page 35

SHELL BUILT-IN COMMANDS

: [arguments] No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.
. filename [arguments] Read and execute commands from filename in the current shell environment and
source filename [arguments] return the exit status of the last command executed from filename. If filename does not contain a slash, pathnames in PATH are used to find the directory containing filename. The file searched for in PATH need not be executable. The current directory is searched if no file is found in PATH. If any arguments are supplied, they become the positional parameters when file is executed. Otherwise, the positional parameters are unchanged. The return status is the status of the last command exited within the script (0 if no commands are executed), and False if filename is not found.
alias [name[=value] ...] alias with no arguments prints the list of aliases in the form name=value on standard output. When arguments are supplied, an alias is defined for each name whose value is given. A trailing space in value causes the next word to be checked for alias substitution when the alias is expanded. For each name in the argument list for which no value is supplied, the name and value of the alias is printed. alias returns True unless a name is given for which no alias has been defined.
bg [jobspec] Place jobspec in the background, as if it had been started with &. If jobspec is not present, the shell's notion of the current job is used. bg jobspec returns 0 unless run when job control is disabled or, when run with job control enabled, if jobspec was not found or started without job control.
bind [_m keymap][_lvd][-q name] Display current readline key and function bindings, or bind a key sequence to a
bind [_m keymap] -f filename readline function or macro. The binding syntax accepted is identical to that of
bind [_m keymap] .inputrc, but each binding must be passed as a separate argument; for example,
keyseq:function-name "\C-x\C-r":re_read_init_file. Options, if supplied, have the following meanings:
_m keymap Use keymap as the keymap to be affected by the subsequent bindings. Acceptable keymap names are emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, vi-command, and vi-insert. vi is equivalent to vi-command; emacs is equivalent to emacs-standard.
_l List the names of all readline functions.
_v List current function names and bindings.
_d Dump function names and bindings in such a way that they can be reread.
_f filename Read key bindings from filename.
_q function Query about which keys invoke the named function.
The return value is 0 unless an unrecognized option is given or an error occurred.
break [n] Exit from within a for, while, or until loop. If n is specified, break n levels. n must be 1. If n is greater than the number of enclosing loops, all enclosing loops are exited. The return value is 0 unless the shell is not executing a loop when break is executed.
builtin shell_builtin [arguments] Execute the specified shell builtin, passing it arguments, and return its exit status. This is useful when you wish to define a function whose name is the same as a shell builtin, but need the functionality of the builtin within the function itself. The cd builtin is commonly redefined this way. The return status is False if shell_builtin is not a shell builtin command.
cd [dir] Change the current directory to dir. The variable HOME is the default dir. The variable CDPATH defines the search path for the directory containing dir. Alternative directory names are separated by a colon (:). A null directory name in CDPATH is the same as the current directory, that is, (.). If dir begins with a slash (/), then CDPATH is

Page 36

not used. An argument of _ is equivalent to $OLDPWD. The return value is True if the directory was successfully changed; False otherwise.
command [-pVv] command [arg ...] Run command with args suppressing the normal shell function lookup. Only built-in commands or commands found in the PATH are executed. If the _p option is given, the search for command is performed using a default value for PATH that is guaranteed to find all of the standard utilities. If either the _V or _v option is supplied, a description of command is printed. The _v option causes a single word indicating the command or pathname used to invoke command to be printed; the _V option produces a more verbose description. An argument of —disables option checking for the rest of the arguments. If the _V or _v option is supplied, the exit status is 0 if command was found, and 1 if not. If neither option is supplied and an error occurred or command cannot be found, the exit status is 127. Otherwise, the exit status of the command builtin is the exit status of command.
continue [n] Resume the next iteration of the enclosing for, while, or until loop. If n is specified, resume at the nth enclosing loop. n must be 1. If n is greater than the number of enclosing loops, the last enclosing loop (the top_level loop) is resumed. The return value is 0 unless the shell is not executing a loop when continue is executed.
declare [_frxi][name[=value]] Declare variables and/or give them attributes. If no names are given, then display the
typeset [_frxi][name[=value]] values of variables instead. The options can be used to restrict output to variables with the specified attribute.
_f Use function names only.
-r Make names read-only. These names cannot then be assigned values by subsequent assignment statements.
_x Mark names for export to subsequent commands via the environment.
_i The variable is treated as an integer; arithmetic evaluation (see "Arithmetic Evaluation") is performed when the variable is assigned a value.
Using + instead of _ turns off the attribute instead. When used in a function, makes names local, as with the local command. The return value is 0 unless an illegal option is encountered, an attempt is made to define a function using "-f foo=bar", one of the names is not a legal shell variable name, an attempt is made to turn off read-only status for a read-only variable, or an attempt is made to display a nonexistent function with -f.
dirs [-l][+/_n] Display the list of currently remembered directories. Directories are added to the list with the pushd command; the popd command moves back up through the list.
+n Displays the nth entry counting from the left of the list shown by dirs when invoked without options, starting with zero.
_n Displays the nth entry counting from the right of the list shown by dirs when invoked without options, starting with zero.
_l Produces a longer listing; the default listing format uses a tilde to denote the home directory.
The return value is 0 unless an illegal option is supplied or n indexes beyond the end of the directory stack.
echo [_neE][arg ...] Output the args, separated by spaces. The return status is always 0. If _n is specified, the trailing newline is suppressed. If the _e option is given, interpretation of the following backslash-escaped characters is enabled. The _E option disables the interpretation of these escape characters, even on systems where they are interpreted by default.

Previous | Table of Contents | Next