.lf 1 ./builtins.1 .\" This is a hack to force bash builtins into the whatis database .\" and to get the list of builtins to come up with the man command. .\" .\" File Name macro. This used to be `.PN', for Path Name, .\" but Sun doesn't seem to like that very much. .\" .de FN \fI\|\\$1\|\fP .. .TH BASH_BUILTINS 1 "2023 January 27" "GNU Bash 5.2" .SH NAME :, ., [, alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, compopt, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc, fg, getopts, hash, help, history, jobs, kill, let, local, logout, mapfile, popd, printf, pushd, pwd, read, readarray, readonly, return, set, shift, shopt, source, suspend, test, times, trap, true, type, typeset, ulimit, umask, unalias, unset, wait \- bash built-in commands, see \fBbash\fR(1) .SH BASH BUILTIN COMMANDS .nr zZ 1 .lf 1 ./bash.1 .\" .\" MAN PAGE COMMENTS to .\" .\" Chet Ramey .\" Case Western Reserve University .\" chet.ramey@case.edu .\" .\" Last Change: Mon Apr 7 16:59:13 EDT 2025 .\" .\" For bash_builtins, strip all but "SHELL BUILTIN COMMANDS" section .\" For rbash, strip all but "RESTRICTED SHELL" section .\" .\" Both conditionalize text based on the base page being formatted .\" using the zZ and zY registers, respectively .\" .\" Ensure the registers are initialized to avoid groff warnings. .nr zZ +0 .nr zY +0 .\" Ensure the macros/strings are initialized to avoid groff warnings. .ds zZ \" empty .ds zY \" empty .PP Unless otherwise noted, each builtin command documented in this section as accepting options preceded by .B \- accepts .B \-\- to signify the end of the options. The \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP/\fB[\fP builtins do not accept options and do not treat \fB\-\-\fP specially. The \fBexit\fP, \fBlogout\fP, \fBreturn\fP, \fBbreak\fP, \fBcontinue\fP, \fBlet\fP, and \fBshift\fP builtins accept and process arguments beginning with \fB\-\fP without requiring \fB\-\-\fP. Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with \fB\-\fP as invalid options and require \fB\-\-\fP to prevent this interpretation. .PP .PD 0 .TP \fB:\fP [\fIarguments\fP] .PD No effect; the command does nothing beyond expanding .I arguments and performing any specified redirections. The return status is zero. .TP \fB\&.\&\fP [\fB\-p\fP \fIpath\fP] \fIfilename\fP [\fIarguments\fP] .PD 0 .TP \fBsource\fP [\fB\-p\fP \fIpath\fP] \fIfilename\fP [\fIarguments\fP] .PD The \fB\&.\&\fP command (\fBsource\fP) reads and execute commands from .I filename in the current shell environment and returns the exit status of the last command executed from .IR filename . .IP If \fIfilename\fP does not contain a slash, \fB\&.\&\fP searches for it. If the \fB\-p\fP option is supplied, \fB\&.\&\fP treats \fIpath\fP as a colon-separated list of directories in which to find \fIfilename\fP; otherwise, \fB\&.\&\fP uses the entries in .SM .B PATH to find the directory containing .IR filename . \fIfilename\fP does not need to be executable. When \fBbash\fP is not in posix mode, it searches the current directory if \fIfilename\fP is not found in .SM .BR PATH , but does not search the current directory if \fB\-p\fP is supplied. If the .B sourcepath option to the .B shopt builtin command is turned off, \fB\&.\&\fP does not search .SM .BR PATH . .IP If any \fIarguments\fP are supplied, they become the positional parameters when \fIfilename\fP is executed. Otherwise the positional parameters are unchanged. .IP If the \fB\-T\fP option is enabled, \fB.\fP inherits any trap on \fBDEBUG\fP; if it is not, any \fBDEBUG\fP trap string is saved and restored around the call to \fB.\fP, and \fB.\fP unsets the \fBDEBUG\fP trap while it executes. If \fB\-T\fP is not set, and the sourced file changes the \fBDEBUG\fP trap, the new value persists after \fB.\fP completes. The return status is the status of the last command executed from \fIfilename\fP (0 if no commands are executed), and non-zero if .I filename is not found or cannot be read. .TP \fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] .\|.\|.] With no arguments or with the .B \-p option, \fBalias\fP prints the list of aliases in the form \fBalias\fP \fIname\fP=\fIvalue\fP on standard output. When arguments are supplied, define an alias for each \fIname\fP whose \fIvalue\fP is given. A trailing space in \fIvalue\fP causes the next word to be checked for alias substitution when the alias is expanded during command parsing. For each \fIname\fP in the argument list for which no \fIvalue\fP is supplied, print the name and value of the alias \fIname\fP. \fBalias\fP returns true unless a \fIname\fP is given (without a corresponding =\fIvalue\fP) for which no alias has been defined. .TP \fBbg\fP [\fIjobspec\fP .\|.\|.] Resume each suspended job \fIjobspec\fP in the background, as if it had been started with .BR & . If .I jobspec is not present, the shell uses its notion of the \fIcurrent job\fP. .B bg .I jobspec returns 0 unless run when job control is disabled or, when run with job control enabled, any specified \fIjobspec\fP was not found or was started without job control. .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lsvSVX\fP] .PD 0 .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP] .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP[:] \fIshell\-command\fP .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-p\fP|\fB\-P\fP [\fIreadline\-command\fP] .TP \fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIreadline\-command\fP .TP \fBbind\fP \fIreadline-command-line\fP .PD Display current .B readline key and function bindings, bind a key sequence to a .B readline function or macro or to a shell command, or set a .B readline variable. Each non-option argument is a key binding or command as it would appear in a .B readline initialization file such as .IR .inputrc , but each binding or command must be passed as a separate argument; e.g., \*'\*"\eC\-x\eC\-r\*": re\-read\-init\-file\*'. In the following descriptions, output available to be re-read is formatted as commands that would appear in a .B readline initialization file or that would be supplied as individual arguments to a .B bind command. Options, if supplied, have the following meanings: .RS .PD 0 .TP .B \-m \fIkeymap\fP Use .I keymap as the keymap to be affected by the subsequent bindings. Acceptable .I keymap names are \fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, vi\-move, vi\-command\fP, and .IR vi\-insert . \fIvi\fP is equivalent to \fIvi\-command\fP (\fIvi\-move\fP is also a synonym); \fIemacs\fP is equivalent to \fIemacs\-standard\fP. .TP .B \-l List the names of all \fBreadline\fP functions. .TP .B \-p Display \fBreadline\fP function names and bindings in such a way that they can be used as an argument to a subsequent \fBbind\fP command or in a \fBreadline\fP initialization file. If arguments remain after option processing, \fBbind\fP treats them as \fBreadline\fP command names and restricts output to those names. .TP .B \-P List current \fBreadline\fP function names and bindings. If arguments remain after option processing, \fBbind\fP treats them as \fBreadline\fP command names and restricts output to those names. .TP .B \-s Display \fBreadline\fP key sequences bound to macros and the strings they output in such a way that they can be used as an argument to a subsequent \fBbind\fP command or in a \fBreadline\fP initialization file. .TP .B \-S Display \fBreadline\fP key sequences bound to macros and the strings they output. .TP .B \-v Display \fBreadline\fP variable names and values in such a way that they can be used as an argument to a subsequent \fBbind\fP command or in a \fBreadline\fP initialization file. .TP .B \-V List current \fBreadline\fP variable names and values. .TP .B \-f \fIfilename\fP Read key bindings from \fIfilename\fP. .TP .B \-q \fIfunction\fP Display key sequences that invoke the named \fBreadline\fP \fIfunction\fP. .TP .B \-u \fIfunction\fP Unbind all key sequences bound to the named \fBreadline\fP \fIfunction\fP. .TP .B \-r \fIkeyseq\fP Remove any current binding for \fIkeyseq\fP. .TP .B \-x \fIkeyseq\fP[: ]\fIshell\-command\fP Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is entered. The separator between \fIkeyseq\fP and \fIshell\-command\fP is either whitespace or a colon optionally followed by whitespace. If the separator is whitespace, \fIshell\-command\fP must be enclosed in double quotes and \fBreadline\fP expands any of its special backslash-escapes in \fIshell\-command\fP before saving it. If the separator is a colon, any enclosing double quotes are optional, and \fBreadline\fP does not expand the command string before saving it. Since the entire key binding expression must be a single argument, it should be enclosed in single quotes. When \fIshell\-command\fP is executed, the shell sets the .SM .B READLINE_LINE variable to the contents of the \fBreadline\fP line buffer and the .SM .B READLINE_POINT and .SM .B READLINE_MARK variables to the current location of the insertion point and the saved insertion point (the mark), respectively. The shell assigns any numeric argument the user supplied to the .SM .B READLINE_ARGUMENT variable. If there was no argument, that variable is not set. If the executed command changes the value of any of .SM .BR READLINE_LINE , .SM .BR READLINE_POINT , or .SM .BR READLINE_MARK , those new values will be reflected in the editing state. .TP .B \-X List all key sequences bound to shell commands and the associated commands in a format that can be reused as an argument to a subsequent \fBbind\fP command. .PD .PP The return value is 0 unless an unrecognized option is supplied or an error occurred. .RE .TP \fBbreak\fP [\fIn\fP] Exit from within a .BR for , .BR while , .BR until , or .B select loop. If \fIn\fP is specified, \fBbreak\fP exits \fIn\fP enclosing loops. .I n must be \(>= 1. If .I n is greater than the number of enclosing loops, all enclosing loops are exited. The return value is 0 unless \fIn\fP is not greater than or equal to 1. .TP \fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP] Execute the specified shell builtin \fIshell\-builtin\fP, passing it .IR arguments , and return its exit status. This is useful when defining a function whose name is the same as a shell builtin, retaining the functionality of the builtin within the function. The \fBcd\fP builtin is commonly redefined this way. The return status is false if .I shell\-builtin is not a shell builtin command. .TP \fBcaller\fP [\fIexpr\fP] Returns the context of any active subroutine call (a shell function or a script executed with the \fB.\fP or \fBsource\fP builtins). .IP Without \fIexpr\fP, \fBcaller\fP displays the line number and source filename of the current subroutine call. If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP displays the line number, subroutine name, and source file corresponding to that position in the current execution call stack. This extra information may be used, for example, to print a stack trace. The current frame is frame 0. .IP The return value is 0 unless the shell is not executing a subroutine call or \fIexpr\fP does not correspond to a valid position in the call stack. .TP .PD 0 \fBcd\fP [\fB\-L\fP] [\fB\-@\fP] [\fIdir\fP] .TP \fBcd\fP \fB\-P\fP [\fB\-e\fP] [\fB\-@\fP] [\fIdir\fP] .PD Change the current directory to \fIdir\fP. if \fIdir\fP is not supplied, the value of the .SM .B HOME shell variable is used as \fIdir\fP. The variable .SM .B CDPATH exists, and \fIdir\fP does not begin with a slash (/), \fBcd\fP uses it as a search path: the shell searches each directory name in .SM .B CDPATH for \fIdir\fP. Alternative directory names in .SM .B CDPATH are separated by a colon (:). A null directory name in .SM .B CDPATH is the same as the current directory, i.e., .Q .\& . .IP The .B \-P option causes \fBcd\fP to use the physical directory structure by resolving symbolic links while traversing \fIdir\fP and before processing instances of .FN .\|.\& in \fIdir\fP (see also the .B \-P option to the .B set builtin command). .IP The .B \-L option forces \fBcd\fP to follow symbolic links by resolving the link after processing instances of .FN .\|.\& in \fIdir\fP. If .FN .\|.\& appears in \fIdir\fP, \fBcd\fP processes it by removing the immediately previous pathname component from \fIdir\fP, back to a slash or the beginning of \fIdir\fP, and verifying that the portion of \fIdir\fP it has processed to that point is still a valid directory name after removing the pathname component. If it is not a valid directory name, \fBcd\fP returns a non-zero status. If neither .B \-L nor .B \-P is supplied, .B cd behaves as if .B \-L had been supplied. .IP If the .B \-e option is supplied with .BR \-P , and \fBcd\fP cannot successfully determine the current working directory after a successful directory change, it returns a non-zero status. .IP On systems that support it, the \fB\-@\fP option presents the extended attributes associated with a file as a directory. .IP An argument of .B \- is converted to .SM .B $OLDPWD before attempting the directory change. .IP If \fBcd\fP uses a non-empty directory name from .SM .BR CDPATH , or if \fB\-\fP is the first argument, and the directory change is successful, \fBcd\fP writes the absolute pathname of the new working directory to the standard output. .IP If the directory change is successful, \fBcd\fP sets the value of the \fBPWD\fP environment variable to the new directory name, and sets the \fBOLDPWD\fP environment variable to the value of the current working directory before the change. .IP The return value is true if the directory was successfully changed; false otherwise. .TP \fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP .\|.\|.] The \fBcommand\fP builtin runs .I command with .I args suppressing the normal shell function lookup for \fIcommand\fP. Only builtin commands or commands found in the .SM .B PATH named \fIcommand\fP are executed. If the .B \-p option is supplied, the search for .I command is performed using a default value for .SM .B PATH that is guaranteed to find all of the standard utilities. .IP If either the .B \-V or .B \-v option is supplied, \fBcommand\fP prints a description of .IR command . The .B \-v option displays a single word indicating the command or filename used to invoke .IR command ; the .B \-V option produces a more verbose description. .IP If the .B \-V or .B \-v option is supplied, the exit status is zero if .I command was found, and non-zero if not. If neither option is supplied and an error occurred or .I command cannot be found, the exit status is 127. Otherwise, the exit status of the .B command builtin is the exit status of .IR command . .TP \fBcompgen\fP [\fB\-V\fP \fIvarname\fP] [\fIoption\fP] [\fIword\fP] Generate possible completion matches for \fIword\fP according to the \fIoption\fPs, which may be any option accepted by the .B complete builtin with the exceptions of .BR \-p , .BR \-r , .BR \-D , .BR \-E , and .BR \-I , and write the matches to the standard output. .IP If the \fB\-V\fP option is supplied, \fBcompgen\fP stores the generated completions into the indexed array variable \fIvarname\fP instead of writing them to the standard output. .IP When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables set by the programmable completion facilities, while available, will not have useful values. .IP The matches will be generated in the same way as if the programmable completion code had generated them directly from a completion specification with the same flags. If \fIword\fP is specified, only those completions matching \fIword\fP will be displayed or stored. .IP The return value is true unless an invalid option is supplied, or no matches were generated. .TP \fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-DEI\fP] [\fB\-A\fP \fIaction\fP] .br [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] .br [\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] \ [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname\fP .\|.\|.] .PD 0 .TP \fBcomplete\fP \fB\-pr\fP [\fB\-DEI\fP] [\fIname\fP .\|.\|.] .PD Specify how arguments to each \fIname\fP should be completed. .IP If the \fB\-p\fP option is supplied, or if no options or \fIname\fPs are supplied, print existing completion specifications in a way that allows them to be reused as input. The \fB\-r\fP option removes a completion specification for each \fIname\fP, or, if no \fIname\fPs are supplied, all completion specifications. .IP The \fB\-D\fP option indicates that other supplied options and actions should apply to the .Q default command completion; that is, completion attempted on a command for which no completion has previously been defined. The \fB\-E\fP option indicates that other supplied options and actions should apply to .Q empty command completion; that is, completion attempted on a blank line. The \fB\-I\fP option indicates that other supplied options and actions should apply to completion on the initial non-assignment word on the line, or after a command delimiter such as \fB;\fP or \fB|\fP, which is usually command name completion. If multiple options are supplied, the \fB\-D\fP option takes precedence over \fB\-E\fP, and both take precedence over \fB\-I\fP. If any of \fB\-D\fP, \fB\-E\fP, or \fB\-I\fP are supplied, any other \fIname\fP arguments are ignored; these completions only apply to the case specified by the option. .IP The process of applying these completion specifications when attempting word completion is described .ie \n(zZ=1 in \fIbash\fP(1). .el above under \fBProgrammable Completion\fP. .IP Other options, if specified, have the following meanings. The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options (and, if necessary, the \fB\-P\fP and \fB\-S\fP options) should be quoted to protect them from expansion before the .B complete builtin is invoked. .IP .RS .PD 0 .TP 8 \fB\-o\fP \fIcomp-option\fP The \fIcomp-option\fP controls several aspects of the compspec's behavior beyond the simple generation of completions. \fIcomp-option\fP may be one of: .RS .TP 8 .B bashdefault Perform the rest of the default \fBbash\fP completions if the compspec generates no matches. .TP 8 .B default Use \fBreadline\fP's default filename completion if the compspec generates no matches. .TP 8 .B dirnames Perform directory name completion if the compspec generates no matches. .TP 8 .B filenames Tell \fBreadline\fP that the compspec generates filenames, so it can perform any filename\-specific processing (such as adding a slash to directory names, quoting special characters, or suppressing trailing spaces). This is intended to be used with shell functions. .TP 8 .B fullquote Tell \fBreadline\fP to quote all the completed words even if they are not filenames. .TP 8 .B noquote Tell \fBreadline\fP not to quote the completed words if they are filenames (quoting filenames is the default). .TP 8 .B nosort Tell \fBreadline\fP not to sort the list of possible completions alphabetically. .TP 8 .B nospace Tell \fBreadline\fP not to append a space (the default) to words completed at the end of the line. .TP 8 .B plusdirs After generating any matches defined by the compspec, attempt directory name completion and add any matches to the results of the other actions. .RE .TP 8 \fB\-A\fP \fIaction\fP The \fIaction\fP may be one of the following to generate a list of possible completions: .RS .TP 8 .B alias Alias names. May also be specified as \fB\-a\fP. .TP 8 .B arrayvar Array variable names. .TP 8 .B binding \fBReadline\fP key binding names. .TP 8 .B builtin Names of shell builtin commands. May also be specified as \fB\-b\fP. .TP 8 .B command Command names. May also be specified as \fB\-c\fP. .TP 8 .B directory Directory names. May also be specified as \fB\-d\fP. .TP 8 .B disabled Names of disabled shell builtins. .TP 8 .B enabled Names of enabled shell builtins. .TP 8 .B export Names of exported shell variables. May also be specified as \fB\-e\fP. .TP 8 .B file File and directory names, similar to \fBreadline\fP's filename completion. May also be specified as \fB\-f\fP. .TP 8 .B function Names of shell functions. .TP 8 .B group Group names. May also be specified as \fB\-g\fP. .TP 8 .B helptopic Help topics as accepted by the \fBhelp\fP builtin. .TP 8 .B hostname Hostnames, as taken from the file specified by the .SM .B HOSTFILE shell variable. .TP 8 .B job Job names, if job control is active. May also be specified as \fB\-j\fP. .TP 8 .B keyword Shell reserved words. May also be specified as \fB\-k\fP. .TP 8 .B running Names of running jobs, if job control is active. .TP 8 .B service Service names. May also be specified as \fB\-s\fP. .TP 8 .B setopt Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin. .TP 8 .B shopt Shell option names as accepted by the \fBshopt\fP builtin. .TP 8 .B signal Signal names. .TP 8 .B stopped Names of stopped jobs, if job control is active. .TP 8 .B user User names. May also be specified as \fB\-u\fP. .TP 8 .B variable Names of all shell variables. May also be specified as \fB\-v\fP. .RE .TP 8 \fB\-C\fP \fIcommand\fP \fIcommand\fP is executed in a subshell environment, and its output is used as the possible completions. Arguments are passed as with the \fB\-F\fP option. .TP 8 \fB\-F\fP \fIfunction\fP The shell function \fIfunction\fP is executed in the current shell environment. When the function is executed, the first argument (\fB$1\fP) is the name of the command whose arguments are being completed, the second argument (\fB$2\fP) is the word being completed, and the third argument (\fB$3\fP) is the word preceding the word being completed on the current command line. When \fIfunction\fP finishes, programmable completion retrieves the possible completions from the value of the .SM .B COMPREPLY array variable. .TP 8 \fB\-G\fP \fIglobpat\fP Expand the pathname expansion pattern \fIglobpat\fP to generate the possible completions. .TP 8 \fB\-P\fP \fIprefix\fP Add \fIprefix\fP to the beginning of each possible completion after all other options have been applied. .TP 8 \fB\-S\fP \fIsuffix\fP Append \fIsuffix\fP to each possible completion after all other options have been applied. .TP 8 \fB\-W\fP \fIwordlist\fP Split the \fIwordlist\fP using the characters in the .SM .B IFS special variable as delimiters, and expand each resulting word. Shell quoting is honored within \fIwordlist\fP, in order to provide a mechanism for the words to contain shell metacharacters or characters in the value of .SM .BR IFS . The possible completions are the members of the resultant list which match a prefix of the word being completed. .TP 8 \fB\-X\fP \fIfilterpat\fP \fIfilterpat\fP is a pattern as used for pathname expansion. It is applied to the list of possible completions generated by the preceding options and arguments, and each completion matching \fIfilterpat\fP is removed from the list. A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this case, any completion not matching \fIfilterpat\fP is removed. .PD .PP The return value is true unless an invalid option is supplied, an option other than .BR \-p , .BR \-r , .BR \-D , .BR \-E , or .B \-I is supplied without a \fIname\fP argument, an attempt is made to remove a completion specification for a \fIname\fP for which no specification exists, or an error occurs adding a completion specification. .RE .TP \fBcompopt\fP [\fB\-o\fP \fIoption\fP] [\fB\-DEI\fP] [\fB+o\fP \fIoption\fP] [\fIname\fP] Modify completion options for each \fIname\fP according to the \fIoption\fPs, or for the currently-executing completion if no \fIname\fPs are supplied. If no \fIoption\fPs are supplied, display the completion options for each \fIname\fP or the current completion. The possible values of \fIoption\fP are those valid for the \fBcomplete\fP builtin described above. .IP The \fB\-D\fP option indicates that other supplied options should apply to the .Q default command completion; the \fB\-E\fP option indicates that other supplied options should apply to .Q empty command completion; and the \fB\-I\fP option indicates that other supplied options should apply to completion on the initial word on the line. These are determined in the same way as the \fBcomplete\fP builtin. .IP If multiple options are supplied, the \fB\-D\fP option takes precedence over \fB\-E\fP, and both take precedence over \fB\-I\fP. .IP The return value is true unless an invalid option is supplied, an attempt is made to modify the options for a \fIname\fP for which no completion specification exists, or an output error occurs. .TP \fBcontinue\fP [\fIn\fP] \fBcontinue\fP resumes the next iteration of the enclosing .BR for , .BR while , .BR until , or .B select loop. If .I n is specified, \fBbash\fP resumes the \fIn\fPth enclosing loop. .I n must be \(>= 1. If .I n is greater than the number of enclosing loops, the shell resumes the last enclosing loop (the .Q top-level loop). The return value is 0 unless \fIn\fP is not greater than or equal to 1. .TP \fBdeclare\fP [\fB\-aAfFgiIlnrtux\fP] [\fB\-p\fP] \ [\fIname\fP[=\fIvalue\fP] .\|.\|.] .PD 0 .TP \fBtypeset\fP [\fB\-aAfFgiIlnrtux\fP] [\fB\-p\fP] \ [\fIname\fP[=\fIvalue\fP] .\|.\|.] .PD Declare variables and/or give them attributes. If no \fIname\fPs are given then display the values of variables or functions. The .B \-p option will display the attributes and values of each .IR name . When .B \-p is used with \fIname\fP arguments, additional options, other than \fB\-f\fP and \fB\-F\fP, are ignored. .IP When .B \-p is supplied without \fIname\fP arguments, \fBdeclare\fP will display the attributes and values of all variables having the attributes specified by the additional options. If no other options are supplied with \fB\-p\fP, \fBdeclare\fP will display the attributes and values of all shell variables. The \fB\-f\fP option restricts the display to shell functions. .IP The .B \-F option inhibits the display of function definitions; only the function name and attributes are printed. If the \fBextdebug\fP shell option is enabled using \fBshopt\fP, the source file name and line number where each \fIname\fP is defined are displayed as well. The .B \-F option implies .BR \-f . .IP The .B \-g option forces variables to be created or modified at the global scope, even when \fBdeclare\fP is executed in a shell function. It is ignored when \fBdeclare\fP is not executed in a shell function. .IP The .B \-I option causes local variables to inherit the attributes (except the \fInameref\fP attribute) and value of any existing variable with the same \fIname\fP at a surrounding scope. If there is no existing variable, the local variable is initially unset. .IP The following options can be used to restrict output to variables with the specified attribute or to give variables attributes: .RS .PD 0 .TP .B \-a Each \fIname\fP is an indexed array variable (see .B Arrays .ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP .B \-A Each \fIname\fP is an associative array variable (see .B Arrays .ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP .B \-f Each \fIname\fP refers to a shell function. .TP .B \-i The variable is treated as an integer; arithmetic evaluation (see .SM .B "ARITHMETIC EVALUATION" .ie \n(zZ=1 in \fIbash\fP(1)) .el above) is performed when the variable is assigned a value. .TP .B \-l When the variable is assigned a value, all upper-case characters are converted to lower-case. The upper-case attribute is disabled. .TP .B \-n Give each \fIname\fP the \fInameref\fP attribute, making it a name reference to another variable. That other variable is defined by the value of \fIname\fP. All references, assignments, and attribute modifications to \fIname\fP, except those using or changing the \fB\-n\fP attribute itself, are performed on the variable referenced by \fIname\fP's value. The nameref attribute cannot be applied to array variables. .TP .B \-r Make \fIname\fPs readonly. These names cannot then be assigned values by subsequent assignment statements or unset. .TP .B \-t Give each \fIname\fP the \fItrace\fP attribute. Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from the calling shell. The trace attribute has no special meaning for variables. .TP .B \-u When the variable is assigned a value, all lower-case characters are converted to upper-case. The lower-case attribute is disabled. .TP .B \-x Mark each \fIname\fP for export to subsequent commands via the environment. .PD .PP Using .Q + instead of .Q \- turns off the specified attribute instead, with the exceptions that \fB+a\fP and \fB+A\fP may not be used to destroy array variables and \fB+r\fP will not remove the readonly attribute. .PP When used in a function, .B declare and .B typeset make each \fIname\fP local, as with the .B local command, unless the \fB\-g\fP option is supplied. If a variable name is followed by =\fIvalue\fP, the value of the variable is set to \fIvalue\fP. When using \fB\-a\fP or \fB\-A\fP and the compound assignment syntax to create array variables, additional attributes do not take effect until subsequent assignments. .PP The return value is 0 unless an invalid option is encountered, an attempt is made to define a function using .Q "\-f foo=bar" , an attempt is made to assign a value to a readonly variable, an attempt is made to assign a value to an array variable without using the compound assignment syntax (see .B Arrays .ie \n(zZ=1 in \fIbash\fP(1)), .el above), one of the \fInames\fP is not a valid shell variable name, an attempt is made to turn off readonly status for a readonly variable, an attempt is made to turn off array status for an array variable, or an attempt is made to display a non-existent function with \fB\-f\fP. .RE .TP .B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP] Without options, display the list of currently remembered directories. The default display is on a single line with directory names separated by spaces. Directories are added to the list with the .B pushd command; the .B popd command removes entries from the list. The current directory is always the first directory in the stack. .IP Options, if supplied, have the following meanings: .RS .PD 0 .TP .B \-c Clears the directory stack by deleting all of the entries. .TP .B \-l Produces a listing using full pathnames; the default listing format uses a tilde to denote the home directory. .TP .B \-p Print the directory stack with one entry per line. .TP .B \-v Print the directory stack with one entry per line, prefixing each entry with its index in the stack. .TP \fB+\fP\fIn\fP Displays the \fIn\fPth entry counting from the left of the list shown by .B dirs when invoked without options, starting with zero. .TP \fB\-\fP\fIn\fP Displays the \fIn\fPth entry counting from the right of the list shown by .B dirs when invoked without options, starting with zero. .PD .PP The return value is 0 unless an invalid option is supplied or \fIn\fP indexes beyond the end of the directory stack. .RE .TP \fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIid\fP .\|.\|.] Without options, remove each .I id from the table of active jobs. Each \fIid\fP may be a job specification \fIjobspec\fP or a process ID \fIpid\fP; if \fIid\fP is a \fIpid\fP, \fBdisown\fP uses the job containing \fIpid\fP as \fIjobspec\fP. .IP If the \fB\-h\fP option is supplied, \fBdisown\fP does not remove the jobs corresponding to each .I id from the jobs table, but rather marks them so the shell does not send .SM .B SIGHUP to the job if the shell receives a .SM .BR SIGHUP . .IP If no .I id is supplied, the .B \-a option means to remove or mark all jobs; the .B \-r option without an .I id argument removes or marks running jobs. If no .I id is supplied, and neither the \fB\-a\fP nor the \fB\-r\fP option is supplied, \fBdisown\fP removes or marks the current job. .IP The return value is 0 unless an .I id does not specify a valid job. .TP \fBecho\fP [\fB\-neE\fP] [\fIarg\fP .\|.\|.] Output the \fIarg\fPs, separated by spaces, followed by a newline. The return status is 0 unless a write error occurs. If \fB\-n\fP is specified, the trailing newline is not printed. .IP If the \fB\-e\fP option is given, \fBecho\fP interprets the following backslash-escaped characters. The .B \-E option disables interpretation of these escape characters, even on systems where they are interpreted by default. The \fBxpg_echo\fP shell option determines whether or not \fBecho\fP interprets any options and expands these escape characters. .B echo does not interpret \fB\-\-\fP to mean the end of options. .IP .B echo interprets the following escape sequences: .RS .PD 0 .TP .B \ea alert (bell) .TP .B \eb backspace .TP .B \ec suppress further output .TP .B \ee .TP .B \eE an escape character .TP .B \ef form feed .TP .B \en new line .TP .B \er carriage return .TP .B \et horizontal tab .TP .B \ev vertical tab .TP .B \e\e backslash .TP .B \e0\fInnn\fP The eight-bit character whose value is the octal value \fInnn\fP (zero to three octal digits). .TP .B \ex\fIHH\fP The eight-bit character whose value is the hexadecimal value \fIHH\fP (one or two hex digits). .TP .B \eu\fIHHHH\fP The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value \fIHHHH\fP (one to four hex digits). .TP .B \eU\fIHHHHHHHH\fP The Unicode (ISO/IEC 10646) character whose value is the hexadecimal value \fIHHHHHHHH\fP (one to eight hex digits). .PD .PP \fBecho\fP writes any unrecognized backslash-escaped characters unchanged. .RE .TP \fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] \ [\fIname\fP .\|.\|.] Enable and disable builtin shell commands. Disabling a builtin allows an executable file which has the same name as a shell builtin to be executed without specifying a full pathname, even though the shell normally searches for builtins before files. .IP If \fB\-n\fP is supplied, each \fIname\fP is disabled; otherwise, \fIname\fPs are enabled. For example, to use the .B test binary found using .SM .B PATH instead of the shell builtin version, run .QN "enable \-n test" . .IP If no \fIname\fP arguments are supplied, or if the .B \-p option is supplied, print a list of shell builtins. With no other option arguments, the list consists of all enabled shell builtins. If \fB\-n\fP is supplied, print only disabled builtins. If \fB\-a\fP is supplied, the list printed includes all builtins, with an indication of whether or not each is enabled. The \fB\-s\fP option means to restrict the output to the .SM POSIX \fIspecial\fP builtins. .IP The .B \-f option means to load the new builtin command .I name from shared object .IR filename , on systems that support dynamic loading. If \fIfilename\fP does not contain a slash, \fBBash\fP will use the value of the \fBBASH_LOADABLES_PATH\fP variable as a colon-separated list of directories in which to search for \fIfilename\fP. The default for \fBBASH_LOADABLES_PATH\fP is system-dependent, and may include .Q .\& to force a search of the current directory. The .B \-d option will delete a builtin previously loaded with \fB\-f\fP. If \fI\-s\fP is used with \fI\-f\fP, the new builtin becomes a .SM POSIX special builtin. .IP If no options are supplied and a \fIname\fP is not a shell builtin, \fBenable\fP will attempt to load \fIname\fP from a shared object named \fIname\fP, as if the command were .QN "enable \-f \fIname name\fP" . .IP The return value is 0 unless a .I name is not a shell builtin or there is an error loading a new builtin from a shared object. .TP \fBeval\fP [\fIarg\fP .\|.\|.] Concatenate the \fIarg\fPs together into a single command, separating them with spaces. \fBBash\fP then reads and execute this command, and returns its exit status as the return status of \fBeval\fP. If there are no .IR args , or only null arguments, .B eval returns 0. .TP \fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]] If .I command is specified, it replaces the shell without creating a new process. \fIcommand\fP cannot be a shell builtin or function. The .I arguments become the arguments to \fIcommand\fP. If the .B \-l option is supplied, the shell places a dash at the beginning of the zeroth argument passed to .IR command . This is what .IR login (1) does. The .B \-c option causes .I command to be executed with an empty environment. If .B \-a is supplied, the shell passes .I name as the zeroth argument to the executed command. .IP If .I command cannot be executed for some reason, a non-interactive shell exits, unless the .B execfail shell option is enabled. In that case, it returns a non-zero status. An interactive shell returns a non-zero status if the file cannot be executed. A subshell exits unconditionally if \fBexec\fP fails. .IP If .I command is not specified, any redirections take effect in the current shell, and the return status is 0. If there is a redirection error, the return status is 1. .TP \fBexit\fP [\fIn\fP] Cause the shell to exit with a status of \fIn\fP. If .I n is omitted, the exit status is that of the last command executed. Any trap on .SM .B EXIT is executed before the shell terminates. .TP \fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIvalue\fP]] .\|.\|. .PD 0 .TP .B export \-p [\fB\-f\fP\^] .PD The supplied .I names are marked for automatic export to the environment of subsequently executed commands. If the .B \-f option is given, the .I names refer to functions. .IP The .B \-n option unexports, or removes the export attribute, from each \fIname\fP. If no .I names are given, or if only the .B \-p option is supplied, \fBexport\fP displays a list of names of all exported variables on the standard output. Using \fB\-p\fP and \fB\-f\fP together displays exported functions. The \fB\-p\fP option displays output in a form that may be reused as input. .IP \fBexport\fP allows the value of a variable to be set when it is exported or unexported by following the variable name with =\fIvalue\fP. This sets the value of the variable to \fIvalue\fP while modifying the export attribute. .B export returns an exit status of 0 unless an invalid option is encountered, one of the \fInames\fP is not a valid shell variable name, or .B \-f is supplied with a .I name that is not a function. .TP \fBfalse\fP Does nothing; returns a non-zero status. .TP \fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP] .PD 0 .TP \fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP] .PD The first form selects a range of commands from .I first to .I last from the history list and displays or edits and re-executes them. .I First and .I last may be specified as a string (to locate the last command beginning with that string) or as a number (an index into the history list, where a negative number is used as an offset from the current command number). .IP When listing, a \fIfirst\fP or \fIlast\fP of 0 is equivalent to \-1 and \-0 is equivalent to the current command (usually the \fBfc\fP command); otherwise 0 is equivalent to \-1 and \-0 is invalid. If .I last is not specified, it is set to the current command for listing (so that .QN "fc \-l \-10" prints the last 10 commands) and to .I first otherwise. If .I first is not specified, it is set to the previous command for editing and \-16 for listing. .IP If the .B \-l option is supplied, the commands are listed on the standard output. The .B \-n option suppresses the command numbers when listing. The .B \-r option reverses the order of the commands. .IP Otherwise, \fBfc\fP invokes the editor named by .I ename on a file containing those commands. If .I ename is not supplied, \fBfc\fP uses the value of the .SM .B FCEDIT variable, and the value of .SM .B EDITOR if .SM .B FCEDIT is not set. If neither variable is set, \fBfc\fP uses .FN vi. When editing is complete, \fBfc\fP reads the file containing the edited commands and echoes and executes them. .IP In the second form, \fBfc\fP re-executes \fIcommand\fP after replacing each instance of \fIpat\fP with \fIrep\fP. \fICommand\fP is interpreted the same as \fIfirst\fP above. .IP A useful alias to use with \fBfc\fP is .Q "r=\*"fc \-s\*"" , so that typing .Q "r cc" runs the last command beginning with .Q cc and typing .Q r re-executes the last command. .IP If the first form is used, the return value is zero unless an invalid option is encountered or .I first or .I last specify history lines out of range. When editing and re-executing a file of commands, the return value is the value of the last command executed or failure if an error occurs with the temporary file. If the second form is used, the return status is that of the re-executed command, unless .I cmd does not specify a valid history entry, in which case .B fc returns a non-zero status. .TP \fBfg\fP [\fIjobspec\fP] Resume .I jobspec in the foreground, and make it the current job. If .I jobspec is not present, \fBfg\fP uses the shell's notion of the \fIcurrent job\fP. The return value is that of the command placed into the foreground, or failure if run when job control is disabled or, when run with job control enabled, if .I jobspec does not specify a valid job or .I jobspec specifies a job that was started without job control. .TP \fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIarg\fP .\|.\|.] .B getopts is used by shell scripts and functions to parse positional parameters and obtain options and their arguments. .I optstring contains the option characters to be recognized; if a character is followed by a colon, the option is expected to have an argument, which should be separated from it by white space. The colon and question mark characters may not be used as option characters. .IP Each time it is invoked, .B getopts places the next option in the shell variable .IR name , initializing .I name if it does not exist, and the index of the next argument to be processed into the variable .SM .BR OPTIND . .SM .B OPTIND is initialized to 1 each time the shell or a shell script is invoked. When an option requires an argument, .B getopts places that argument into the variable .SM .BR OPTARG . .IP The shell does not reset .SM .B OPTIND automatically; it must be manually reset between multiple calls to .B getopts within the same shell invocation to use a new set of parameters. .IP When it reaches the end of options, \fBgetopts\fP exits with a return value greater than zero. .SM .B OPTIND is set to the index of the first non-option argument, and \fIname\fP is set to ?. .IP .B getopts normally parses the positional parameters, but if more arguments are supplied as .I arg values, .B getopts parses those instead. .IP .B getopts can report errors in two ways. If the first character of .I optstring is a colon, \fBgetopts\fP uses .I silent error reporting. In normal operation, \fBgetopts\fP prints diagnostic messages when it encounters invalid options or missing option arguments. If the variable .SM .B OPTERR is set to 0, .B getopts does not display any error messages, even if the first character of .I optstring is not a colon. .IP If .B getopts detects an invalid option, it places ? into .I name and, if not silent, prints an error message and unsets .SM .BR OPTARG . If .B getopts is silent, it assigns the option character found to .SM .B OPTARG and does not print a diagnostic message. .IP If a required argument is not found, and .B getopts is not silent, it sets the value of \fIname\fP to a question mark (\^\fB?\fP\^), unsets .SM .BR OPTARG , and prints a diagnostic message. If .B getopts is silent, it sets the value of \fIname\fP to a colon (\^\fB:\fP\^) and sets .SM .B OPTARG to the option character found. .IP .B getopts returns true if an option, specified or unspecified, is found. It returns false if the end of options is encountered or an error occurs. .TP \fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP] Each time \fBhash\fP is invoked, it remembers the full pathname of the command .I name as determined by searching the directories in .BR $PATH . Any previously-remembered pathname associated with \fIname\fP is discarded. If the .B \-p option is supplied, \fBhash\fP uses .I filename as the full pathname of the command. .IP The .B \-r option causes the shell to forget all remembered locations. Assigning to the \fBPATH\fP variable also clears all hashed filenames. The .B \-d option causes the shell to forget the remembered location of each \fIname\fP. .IP If the .B \-t option is supplied, \fBhash\fP prints the full pathname corresponding to each \fIname\fP. If multiple \fIname\fP arguments are supplied with \fB\-t\fP, \fBhash\fP prints the \fIname\fP before the corresponding hashed full pathname. The .B \-l option displays output in a format that may be reused as input. .IP If no arguments are given, or if only \fB\-l\fP is supplied, \fBhash\fP prints information about remembered commands. The \fB\-t\fP, \fB\-d\fP, and \fB\-p\fP options (the options that act on the \fIname\fP arguments) are mutually exclusive. Only one will be active. If more than one is supplied, \fB\-t\fP has higher priority than \fB\-p\fP, and both have higher priority than \fB\-d\fP. .IP The return status is zero unless a .I name is not found or an invalid option is supplied. .TP \fBhelp\fP [\fB\-dms\fP] [\fIpattern\fP] Display helpful information about builtin commands. If .I pattern is specified, .B help gives detailed help on all commands matching .I pattern as described below; otherwise it displays a list of all the builtins and shell compound commands. .IP Options, if supplied, have the follow meanings: .RS .TP .PD 0 .B \-d Display a short description of each \fIpattern\fP .TP .B \-m Display the description of each \fIpattern\fP in a manpage-like format .TP .B \-s Display only a short usage synopsis for each \fIpattern\fP .PD .RE .IP If \fIpattern\fP contains pattern matching characters (see .SM .B "Pattern Matching" above) it's treated as a shell pattern and \fBhelp\fP prints the description of each help topic matching \fIpattern\fP. .IP If not, and \fIpattern\fP exactly matches the name of a help topic, \fBhelp\fP prints the description associated with that topic. Otherwise, \fBhelp\fP performs prefix matching and prints the descriptions of all matching help topics. .IP The return status is 0 unless no command matches .IR pattern . .TP \fBhistory [\fIn\fP] .PD 0 .TP \fBhistory\fP \fB\-c\fP .TP \fBhistory \-d\fP \fIoffset\fP .TP \fBhistory \-d\fP \fIstart\fP-\fIend\fP .TP \fBhistory\fP \fB\-anrw\fP [\fIfilename\fP] .TP \fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg\fP .\|.\|.] .TP \fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg\fP .\|.\|.] .PD With no options, display the command history list with numbers. Entries prefixed with a .B * have been modified. An argument of .I n lists only the last .I n entries. If the shell variable .SM .B HISTTIMEFORMAT is set and not null, it is used as a format string for .IR strftime (3) to display the time stamp associated with each displayed history entry. If .B history uses .SM .BR HISTTIMEFORMAT , it does not print an intervening space between the formatted time stamp and the history entry. .IP If \fIfilename\fP is supplied, \fBhistory\fP uses it as the name of the history file; if not, it uses the value of .SM .BR HISTFILE . If \fIfilename\fP is not supplied and .SM .B HISTFILE is unset or null, the \fB\-a, \-n, \-r,\fP and \fB\-w\fP options have no effect. .IP Options, if supplied, have the following meanings: .RS .PD 0 .TP .B \-c Clear the history list by deleting all the entries. This can be used with the other options to replace the history list. .TP \fB\-d\fP \fIoffset\fP Delete the history entry at position \fIoffset\fP. If \fIoffset\fP is negative, it is interpreted as relative to one greater than the last history position, so negative indices count back from the end of the history, and an index of \-1 refers to the current \fBhistory \-d\fP command. .TP \fB\-d\fP \fIstart\fP\-\fIend\fP Delete the range of history entries between positions \fIstart\fP and \fIend\fP, inclusive. Positive and negative values for \fIstart\fP and \fIend\fP are interpreted as described above. .TP .B \-a Append the .Q new history lines to the history file. These are history lines entered since the beginning of the current \fBbash\fP session, but not already appended to the history file. .TP .B \-n Read the history lines not already read from the history file and add them to the current history list. These are lines appended to the history file since the beginning of the current \fBbash\fP session. .TP .B \-r Read the history file and append its contents to the current history list. .TP .B \-w Write the current history list to the history file, overwriting the history file. .TP .B \-p Perform history substitution on the following \fIargs\fP and display the result on the standard output, without storing the results in the history list. Each \fIarg\fP must be quoted to disable normal history expansion. .TP .B \-s Store the .I args in the history list as a single entry. The last command in the history list is removed before adding the .IR args . .PD .RE .IP If the .SM .B HISTTIMEFORMAT variable is set, \fBhistory\fP writes the time stamp information associated with each history entry to the history file, marked with the history comment character as described above. When the history file is read, lines beginning with the history comment character followed immediately by a digit are interpreted as timestamps for the following history entry. .IP The return value is 0 unless an invalid option is encountered, an error occurs while reading or writing the history file, an invalid \fIoffset\fP or range is supplied as an argument to \fB\-d\fP, or the history expansion supplied as an argument to \fB\-p\fP fails. .TP \fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP .\|.\|. ] .PD 0 .TP \fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP .\|.\|. ] .PD The first form lists the active jobs. The options have the following meanings: .RS .PD 0 .TP .B \-l List process IDs in addition to the normal information. .TP .B \-n Display information only about jobs that have changed status since the user was last notified of their status. .TP .B \-p List only the process ID of the job's process group leader. .TP .B \-r Display only running jobs. .TP .B \-s Display only stopped jobs. .PD .RE .IP If .I jobspec is supplied, \fBjobs\fP restricts output to information about that job. The return status is 0 unless an invalid option is encountered or an invalid .I jobspec is supplied. .IP If the .B \-x option is supplied, .B jobs replaces any .I jobspec found in .I command or .I args with the corresponding process group ID, and executes .IR command , passing it .IR args , returning its exit status. .TP \fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] \ \fIid\fP [ .\|.\|. ] .PD 0 .TP \fBkill\fP \fB\-l\fP|\fB\-L\fP [\fIsigspec\fP | \fIexit_status\fP] .PD Send the signal specified by .I sigspec or .I signum to the processes named by each .IR id . Each .I id may be a job specification \fIjobspec\fP or a process ID \fIpid\fP. .I sigspec is either a case-insensitive signal name such as .SM .B SIGKILL (with or without the .SM .B SIG prefix) or a signal number; .I signum is a signal number. If .I sigspec is not supplied, then .B kill sends .SM .BR SIGTERM . .IP The .B \-l option lists the signal names. If any arguments are supplied when .B \-l is given, .B kill lists the names of the signals corresponding to the arguments, and the return status is 0. The \fIexit_status\fP argument to .B \-l is a number specifying either a signal number or the exit status of a process terminated by a signal; if it is supplied, \fBkill\fP prints the name of the signal that caused the process to terminate. \fBkill\fP assumes that process exit statuses are greater than 128; anything less than that is a signal number. The .B \-L option is equivalent to \fB\-l\fP. .IP .B kill returns true if at least one signal was successfully sent, or false if an error occurs or an invalid option is encountered. .TP \fBlet\fP \fIarg\fP [\fIarg\fP .\|.\|.] Each .I arg is evaluated as an arithmetic expression (see .SM .B "ARITHMETIC EVALUATION" .ie \n(zZ=1 in \fIbash\fP(1)). .el above). If the last .I arg evaluates to 0, .B let returns 1; otherwise .B let returns 0. .TP \fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] .\|.\|. | \- ] For each argument, create a local variable named .I name and assign it .IR value . The \fIoption\fP can be any of the options accepted by \fBdeclare\fP. When .B local is used within a function, it causes the variable .I name to have a visible scope restricted to that function and its children. It is an error to use .B local when not within a function. .IP If \fIname\fP is \-, it makes the set of shell options local to the function in which \fBlocal\fP is invoked: any shell options changed using the \fBset\fP builtin inside the function after the call to \fBlocal\fP are restored to their original values when the function returns. The restore is performed as if a series of \fBset\fP commands were executed to restore the values that were in place before the function. .IP With no operands, .B local writes a list of local variables to the standard output. .IP The return status is 0 unless .B local is used outside a function, an invalid .I name is supplied, or \fIname\fP is a readonly variable. .TP .B logout [\fIn\fP] Exit a login shell, returning a status of \fIn\fP to the shell's parent. .TP \fBmapfile\fP [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] .PD 0 .TP \fBreadarray\fP [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] .PD Read lines from the standard input, or from file descriptor .I fd if the .B \-u option is supplied, into the indexed array variable .IR array . The variable .SM .B MAPFILE is the default \fIarray\fP. Options, if supplied, have the following meanings: .RS .PD 0 .TP .B \-d Use the first character of \fIdelim\fP to terminate each input line, rather than newline. If \fIdelim\fP is the empty string, \fBmapfile\fP will terminate a line when it reads a NUL character. .TP .B \-n Copy at most .I count lines. If \fIcount\fP is 0, copy all lines. .TP .B \-O Begin assigning to .I array at index .IR origin . The default index is 0. .TP .B \-s Discard the first \fIcount\fP lines read. .TP .B \-t Remove a trailing \fIdelim\fP (default newline) from each line read. .TP .B \-u Read lines from file descriptor \fIfd\fP instead of the standard input. .TP .B \-C Evaluate .I callback each time \fIquantum\fP lines are read. The \fB\-c\fP option specifies .IR quantum . .TP .B \-c Specify the number of lines read between each call to .IR callback . .PD .RE .IP If .B \-C is specified without .BR \-c , the default quantum is 5000. When \fIcallback\fP is evaluated, it is supplied the index of the next array element to be assigned and the line to be assigned to that element as additional arguments. \fIcallback\fP is evaluated after the line is read but before the array element is assigned. .IP If not supplied with an explicit origin, \fBmapfile\fP will clear \fIarray\fP before assigning to it. .IP \fBmapfile\fP returns zero unless an invalid option or option argument is supplied, \fIarray\fP is invalid or unassignable, or if \fIarray\fP is not an indexed array. .TP \fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP] Remove entries from the directory stack. The elements are numbered from 0 starting at the first directory listed by \fBdirs\fP, so \fBpopd\fP is equivalent to .Q "popd +0." With no arguments, \fBpopd\fP removes the top directory from the stack, and changes to the new top directory. Arguments, if supplied, have the following meanings: .RS .PD 0 .TP .B \-n Suppress the normal change of directory when removing directories from the stack, only manipulate the stack. .TP \fB+\fP\fIn\fP Remove the \fIn\fPth entry counting from the left of the list shown by .BR dirs , starting with zero, from the stack. For example: .Q "popd +0" removes the first directory, .Q "popd +1" the second. .TP \fB\-\fP\fIn\fP Remove the \fIn\fPth entry counting from the right of the list shown by .BR dirs , starting with zero. For example: .Q "popd \-0" removes the last directory, .Q "popd \-1" the next to last. .PD .RE .IP If the top element of the directory stack is modified, and the \fI\-n\fP option was not supplied, \fBpopd\fP uses the \fBcd\fP builtin to change to the directory at the top of the stack. If the \fBcd\fP fails, \fBpopd\fP returns a non-zero value. .IP Otherwise, .B popd returns false if an invalid option is supplied, the directory stack is empty, or \fIn\fP specifies a non-existent directory stack entry. .IP If the .B popd command is successful, \fBbash\fP runs .B dirs to show the final contents of the directory stack, and the return status is 0. .TP \fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP] Write the formatted \fIarguments\fP to the standard output under the control of the \fIformat\fP. The \fB\-v\fP option assigns the output to the variable \fIvar\fP rather than printing it to the standard output. .IP The \fIformat\fP is a character string which contains three types of objects: plain characters, which are simply copied to standard output, character escape sequences, which are converted and copied to the standard output, and format specifications, each of which causes printing of the next successive \fIargument\fP. In addition to the standard .IR printf (3) format characters .BR cCsSndiouxXeEfFgGaA , \fBprintf\fP interprets the following additional format specifiers: .RS .PD 0 .TP .B %b causes \fBprintf\fP to expand backslash escape sequences in the corresponding \fIargument\fP in the same way as \fBecho \-e\fP. .TP .B %q causes \fBprintf\fP to output the corresponding \fIargument\fP in a format that can be reused as shell input. \fB%q\fP and \fB%Q\fP use the \fB$\*'\*'\fP quoting style if any characters in the argument string require it, and backslash quoting otherwise. If the format string uses the \fIprintf\fP alternate form, these two formats quote the argument string using single quotes. .TP .B %Q like \fB%q\fP, but applies any supplied precision to the \fIargument\fP before quoting it. .TP .B %(\fIdatefmt\fP)T causes \fBprintf\fP to output the date-time string resulting from using \fIdatefmt\fP as a format string for .IR strftime (3). The corresponding \fIargument\fP is an integer representing the number of seconds since the epoch. This format specifier recognizes two special argument values: \-1 represents the current time, and \-2 represents the time the shell was invoked. If no argument is specified, conversion behaves as if \-1 had been supplied. This is an exception to the usual \fBprintf\fP behavior. .PD .RE .IP The %b, %q, and %T format specifiers all use the field width and precision arguments from the format specification and write that many bytes from (or use that wide a field for) the expanded argument, which usually contains more characters than the original. .IP The %n format specifier accepts a corresponding argument that is treated as a shell variable name. .IP The %s and %c format specifiers accept an l (long) modifier, which forces them to convert the argument string to a wide-character string and apply any supplied field width and precision in terms of characters, not bytes. The %S and %C format specifiers are equivalent to %ls and %lc, respectively. .\" .IP .\" The %s format specifier understands the "altform" flag (#) and behaves .\" identically to the %b format specifier if it's supplied. .IP Arguments to non-string format specifiers are treated as C constants, except that a leading plus or minus sign is allowed, and if the leading character is a single or double quote, the value is the numeric value of the following character, using the current locale. .IP The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP. If the \fIformat\fP requires more \fIarguments\fP than are supplied, the extra format specifications behave as if a zero value or null string, as appropriate, had been supplied. The return value is zero on success, non-zero if an invalid option is supplied or a write or assignment error occurs. .TP \fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP] .PD 0 .TP \fBpushd\fP [\fB\-n\fP] [\fIdir\fP] .PD Add a directory to the top of the directory stack, or rotate the stack, making the new top of the stack the current working directory. With no arguments, \fBpushd\fP exchanges the top two elements of the directory stack. Arguments, if supplied, have the following meanings: .RS .PD 0 .TP .B \-n Suppress the normal change of directory when rotating or adding directories to the stack, only manipulate the stack. .TP \fB+\fP\fIn\fP Rotate the stack so that the \fIn\fPth directory (counting from the left of the list shown by .BR dirs , starting with zero) is at the top. .TP \fB\-\fP\fIn\fP Rotates the stack so that the \fIn\fPth directory (counting from the right of the list shown by .BR dirs , starting with zero) is at the top. .TP .I dir Adds .I dir to the directory stack at the top. .PD .RE .IP After the stack has been modified, if the \fB\-n\fP option was not supplied, \fBpushd\fP uses the \fBcd\fP builtin to change to the directory at the top of the stack. If the \fBcd\fP fails, \fBpushd\fP returns a non-zero value. .IP Otherwise, if no arguments are supplied, .B pushd returns zero unless the directory stack is empty. When rotating the directory stack, .B pushd returns zero unless the directory stack is empty or \fIn\fP specifies a non-existent directory stack element. .IP If the .B pushd command is successful, \fBbash\fP runs .B dirs to show the final contents of the directory stack. .TP \fBpwd\fP [\fB\-LP\fP] Print the absolute pathname of the current working directory. The pathname printed contains no symbolic links if the .B \-P option is supplied or the .B \-o physical option to the .B set builtin command is enabled. If the .B \-L option is used, the pathname printed may contain symbolic links. The return status is 0 unless an error occurs while reading the name of the current directory or an invalid option is supplied. .TP \fBread\fP [\fB\-Eers\fP] [\fB\-a\fP \fIaname\fP] \ [\fB\-d\fP \fIdelim\fP] [\fB\-i\fP \fItext\fP] \ [\fB\-n\fP \fInchars\fP] [\fB\-N\fP \fInchars\fP] \ [\fB\-p\fP \fIprompt\fP] [\fB\-t\fP \fItimeout\fP] \ [\fB\-u\fP \fIfd\fP] [\fIname\fP .\|.\|.] Read one line from the standard input, or from the file descriptor \fIfd\fP supplied as an argument to the \fB\-u\fP option, split it into words as described .ie \n(zZ=1 in \fIbash\fP (1) .el above under \fBWord Splitting\fP, and assign the first word to the first .IR name , the second word to the second .IR name , and so on. If there are more words than names, the remaining words and their intervening delimiters are assigned to the last .IR name . If there are fewer words read from the input stream than names, the remaining names are assigned empty values. The characters in the value of the .SM .B IFS variable are used to split the line into words using the same rules the shell uses for expansion (described .ie \n(zZ=1 in \fIbash\fP (1) .el above under \fBWord Splitting\fP). The backslash character (\fB\e\fP) removes any special meaning for the next character read and is used for line continuation. .IP Options, if supplied, have the following meanings: .RS .PD 0 .TP .B \-a \fIaname\fP The words are assigned to sequential indices of the array variable .IR aname , starting at 0. .I aname is unset before any new values are assigned. Other \fIname\fP arguments are ignored. .TP .B \-d \fIdelim\fP The first character of \fIdelim\fP terminates the input line, rather than newline. If \fIdelim\fP is the empty string, \fBread\fP will terminate a line when it reads a NUL character. .TP .B \-e If the standard input is coming from a terminal, \fBread\fP uses .B readline (see .SM .B READLINE .ie \n(zZ=1 in \fIbash\fP(1)) .el above) to obtain the line. \fBReadline\fP uses the current (or default, if line editing was not previously active) editing settings, but uses \fBreadline\fP's default filename completion. .TP .B \-E If the standard input is coming from a terminal, \fBread\fP uses .B readline (see .SM .B READLINE .ie \n(zZ=1 in \fIbash\fP(1)) .el above) to obtain the line. .B Readline uses the current (or default, if line editing was not previously active) editing settings, but uses bash's default completion, including programmable completion. .TP .B \-i \fItext\fP If .B readline is being used to read the line, \fBread\fP places \fItext\fP into the editing buffer before editing begins. .TP .B \-n \fInchars\fP \fBread\fP returns after reading \fInchars\fP characters rather than waiting for a complete line of input, unless it encounters EOF or \fBread\fP times out, but honors a delimiter if it reads fewer than \fInchars\fP characters before the delimiter. .TP .B \-N \fInchars\fP \fBread\fP returns after reading exactly \fInchars\fP characters rather than waiting for a complete line of input, unless it encounters EOF or \fBread\fP times out. Any delimiter characters in the input are not treated specially and do not cause \fBread\fP to return until it has read \fInchars\fP characters. The result is not split on the characters in \fBIFS\fP; the intent is that the variable is assigned exactly the characters read (with the exception of backslash; see the \fB\-r\fP option below). .TP .B \-p \fIprompt\fP Display \fIprompt\fP on standard error, without a trailing newline, before attempting to read any input, but only if input is coming from a terminal. .TP .B \-r Backslash does not act as an escape character. The backslash is considered to be part of the line. In particular, a backslash-newline pair may not then be used as a line continuation. .TP .B \-s Silent mode. If input is coming from a terminal, characters are not echoed. .TP .B \-t \fItimeout\fP Cause \fBread\fP to time out and return failure if it does not read a complete line of input (or a specified number of characters) within \fItimeout\fP seconds. \fItimeout\fP may be a decimal number with a fractional portion following the decimal point. This option is only effective if \fBread\fP is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. If \fBread\fP times out, it saves any partial input read into the specified variable \fIname\fP, and the exit status is greater than 128. If \fItimeout\fP is 0, \fBread\fP returns immediately, without trying to read any data. In this case, the exit status is 0 if input is available on the specified file descriptor, or the read will return EOF, non-zero otherwise. .TP .B \-u \fIfd\fP Read input from file descriptor \fIfd\fP instead of the standard input. .PD .RE .IP Other than the case where \fIdelim\fP is the empty string, \fBread\fP ignores any NUL characters in the input. .IP If no .I names are supplied, \fBread\fP assigns the line read, without the ending delimiter but otherwise unmodified, to the variable .SM .BR REPLY . .IP The exit status is zero, unless end-of-file is encountered, \fBread\fP times out (in which case the status is greater than 128), a variable assignment error (such as assigning to a readonly variable) occurs, or an invalid file descriptor is supplied as the argument to \fB\-u\fP. .TP \fBreadonly\fP [\fB\-aAf\fP] [\fB\-p\fP] [\fIname\fP[=\fIword\fP] .\|.\|.] .PD The given \fInames\fP are marked readonly; the values of these .I names may not be changed by subsequent assignment or unset. If the .B \-f option is supplied, each \fIname\fP refers to a shell function. The .B \-a option restricts the variables to indexed arrays; the .B \-A option restricts the variables to associative arrays. If both options are supplied, .B \-A takes precedence. If no .I name arguments are supplied, or if the .B \-p option is supplied, print a list of all readonly names. The other options may be used to restrict the output to a subset of the set of readonly names. The .B \-p option displays output in a format that may be reused as input. .IP \fBreadonly\fP allows the value of a variable to be set at the same time the readonly attribute is changed by following the variable name with =\fIvalue\fP. This sets the value of the variable is to \fIvalue\fP while modifying the readonly attribute. .IP The return status is 0 unless an invalid option is encountered, one of the .I names is not a valid shell variable name, or .B \-f is supplied with a .I name that is not a function. .TP \fBreturn\fP [\fIn\fP] Stop executing a shell function or sourced file and return the value specified by .I n to its caller. If .I n is omitted, the return status is that of the last command executed. If \fBreturn\fP is executed by a trap handler, the last command used to determine the status is the last command executed before the trap handler. If \fBreturn\fP is executed during a \fBDEBUG\fP trap, the last command used to determine the status is the last command executed by the trap handler before \fBreturn\fP was invoked. .IP When .B return is used to terminate execution of a script being executed by the .B . (\fBsource\fP) command, it causes the shell to stop executing that script and return either .I n or the exit status of the last command executed within the script as the exit status of the script. If \fIn\fP is supplied, the return value is its least significant 8 bits. .IP Any command associated with the \fBRETURN\fP trap is executed before execution resumes after the function or script. .IP The return status is non-zero if .B return is supplied a non-numeric argument, or is used outside a function and not during execution of a script by \fB.\fP\^ or \fBsource\fP. .TP \fBset\fP [\fB\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\-name\fP] \ [\fB\-\-\fP] [\fB\-\fP] [\fIarg\fP .\|.\|.] .PD 0 .TP \fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\-name\fP] \ [\fB\-\-\fP] [\fB\-\fP] [\fIarg\fP .\|.\|.] .TP \fBset \-o\fP .TP \fBset +o\fP .PD Without options, display the name and value of each shell variable in a format that can be reused as input for setting or resetting the currently-set variables. Read-only variables cannot be reset. In posix mode, only shell variables are listed. The output is sorted according to the current locale. When options are specified, they set or unset shell attributes. Any arguments remaining after option processing are treated as values for the positional parameters and are assigned, in order, to .BR $1 , .BR $2 , \&.\|.\|., .BR $\fIn\fP . Options, if specified, have the following meanings: .RS .PD 0 .TP 8 .B \-a Each variable or function that is created or modified is given the export attribute and marked for export to the environment of subsequent commands. .TP 8 .B \-b Report the status of terminated background jobs immediately, rather than before the next primary prompt or after a foreground command terminates. This is effective only when job control is enabled. .TP 8 .B \-e .PD Exit immediately if a \fIpipeline\fP (which may consist of a single \fIsimple command\fP), a \fIlist\fP, or a \fIcompound command\fP (see .SM .B "SHELL GRAMMAR" .ie \n(zZ=1 in \fIbash\fP(1)), .el above), exits with a non-zero status. The shell does not exit if the command that fails is part of the command list immediately following a .B while or .B until reserved word, part of the test following the .B if or .B elif reserved words, part of any command executed in a .B && or .B || list except the command following the final \fB&&\fP or \fB||\fP, any command in a pipeline but the last (subject to the state of the \fBpipefail\fP shell option), or if the command's return value is being inverted with .BR ! . If a compound command other than a subshell returns a non-zero status because a command failed while \fB\-e\fP was being ignored, the shell does not exit. A trap on \fBERR\fP, if set, is executed before the shell exits. This option applies to the shell environment and each subshell environment separately (see .SM .B "COMMAND EXECUTION ENVIRONMENT" .ie \n(zZ=1 in \fIbash\fP(1)), .el above), and may cause subshells to exit before executing all the commands in the subshell. .IP If a compound command or shell function executes in a context where \fB\-e\fP is being ignored, none of the commands executed within the compound command or function body will be affected by the \fB\-e\fP setting, even if \fB\-e\fP is set and a command returns a failure status. If a compound command or shell function sets \fB\-e\fP while executing in a context where \fB\-e\fP is ignored, that setting will not have any effect until the compound command or the command containing the function call completes. .PD 0 .TP 8 .B \-f Disable pathname expansion. .TP 8 .B \-h Remember the location of commands as they are looked up for execution. This is enabled by default. .TP 8 .B \-k All arguments in the form of assignment statements are placed in the environment for a command, not just those that precede the command name. .TP 8 .B \-m Monitor mode. Job control is enabled. This option is on by default for interactive shells on systems that support it (see .SM .B "JOB CONTROL" .ie \n(zZ=1 in \fIbash\fP(1)). .el above). All processes run in a separate process group. When a background job completes, the shell prints a line containing its exit status. .TP 8 .B \-n Read commands but do not execute them. This may be used to check a shell script for syntax errors. This is ignored by interactive shells. .TP 8 .B \-o \fIoption\-name\fP The \fIoption\-name\fP can be one of the following: .RS .TP 8 .B allexport Same as .BR \-a . .TP 8 .B braceexpand Same as .BR \-B . .TP 8 .B emacs Use an emacs-style command line editing interface. This is enabled by default when the shell is interactive, unless the shell is started with the .B \-\-noediting option. This also affects the editing interface used for \fBread \-e\fP. .TP 8 .B errexit Same as .BR \-e . .TP 8 .B errtrace Same as .BR \-E . .TP 8 .B functrace Same as .BR \-T . .TP 8 .B hashall Same as .BR \-h . .TP 8 .B histexpand Same as .BR \-H . .TP 8 .B history Enable command history, as described .ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM .BR HISTORY . This option is on by default in interactive shells. .TP 8 .B ignoreeof The effect is as if the shell command .QN "IGNOREEOF=10" had been executed (see .B "Shell Variables" .ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP 8 .B keyword Same as .BR \-k . .TP 8 .B monitor Same as .BR \-m . .TP 8 .B noclobber Same as .BR \-C . .TP 8 .B noexec Same as .BR \-n . .TP 8 .B noglob Same as .BR \-f . .TP 8 .B nolog Currently ignored. .TP 8 .B notify Same as .BR \-b . .TP 8 .B nounset Same as .BR \-u . .TP 8 .B onecmd Same as .BR \-t . .TP 8 .B physical Same as .BR \-P . .TP 8 .B pipefail If set, the return value of a pipeline is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default. .TP 8 .B posix Enable posix mode; change the behavior of .B bash where the default operation differs from the .SM POSIX standard to match the standard. See .SM .B "SEE ALSO" .ie \n(zZ=1 in \fIbash\fP(1) .el below for a reference to a document that details how posix mode affects bash's behavior. .TP 8 .B privileged Same as .BR \-p . .TP 8 .B verbose Same as .BR \-v . .TP 8 .B vi Use a vi-style command line editing interface. This also affects the editing interface used for \fBread \-e\fP. .TP 8 .B xtrace Same as .BR \-x . .PP If .B \-o is supplied with no \fIoption\-name\fP, \fBset\fP prints the current shell option settings. If .B +o is supplied with no \fIoption\-name\fP, \fBset\fP prints a series of .B set commands to recreate the current option settings on the standard output. .RE .TP 8 .B \-p Turn on .I privileged mode. In this mode, the shell does not read the .SM .B $ENV and .SM .B $BASH_ENV files, shell functions are not inherited from the environment, and the .SM .BR SHELLOPTS , .SM .BR BASHOPTS , .SM .BR CDPATH , and .SM .B GLOBIGNORE variables, if they appear in the environment, are ignored. If the shell is started with the effective user (group) id not equal to the real user (group) id, and the \fB\-p\fP option is not supplied, these actions are taken and the effective user id is set to the real user id. If the \fB\-p\fP option is supplied at startup, the effective user id is not reset. Turning this option off causes the effective user and group ids to be set to the real user and group ids. .TP 8 .B \-r Enable restricted shell mode. This option cannot be unset once it has been set. .TP 8 .B \-t Exit after reading and executing one command. .TP 8 .B \-u Treat unset variables and parameters other than the special parameters .Q @ and .Q * , or array variables subscripted with .Q @ or .Q * , as an error when performing parameter expansion. If expansion is attempted on an unset variable or parameter, the shell prints an error message, and, if not interactive, exits with a non-zero status. .TP 8 .B \-v Print shell input lines as they are read. .TP 8 .B \-x After expanding each \fIsimple command\fP, \fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or arithmetic \fBfor\fP command, display the expanded value of .SM .BR PS4 , followed by the command and its expanded arguments or associated word list, to the standard error. .TP 8 .B \-B The shell performs brace expansion (see .B "Brace Expansion" .ie \n(zZ=1 in \fIbash\fP(1)). .el above). This is on by default. .TP 8 .B \-C If set, .B bash does not overwrite an existing file with the .BR > , .BR >& , and .B <> redirection operators. Using the redirection operator .B >| instead of .B > will override this and force the creation of an output file. .TP 8 .B \-E If set, any trap on \fBERR\fP is inherited by shell functions, command substitutions, and commands executed in a subshell environment. The \fBERR\fP trap is normally not inherited in such cases. .TP 8 .B \-H Enable .B ! style history substitution. This option is on by default when the shell is interactive. .TP 8 .B \-P If set, the shell does not resolve symbolic links when executing commands such as .B cd that change the current working directory. It uses the physical directory structure instead. By default, .B bash follows the logical chain of directories when performing commands which change the current directory. .TP 8 .B \-T If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell functions, command substitutions, and commands executed in a subshell environment. The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited in such cases. .TP 8 .B \-\- If no arguments follow this option, unset the positional parameters. Otherwise, set the positional parameters to the \fIarg\fPs, even if some of them begin with a .BR \- . .TP 8 .B \- Signal the end of options, and assign all remaining \fIarg\fPs to the positional parameters. The .B \-x and .B \-v options are turned off. If there are no \fIarg\fPs, the positional parameters remain unchanged. .PD .PP The options are off by default unless otherwise noted. Using + rather than \- causes these options to be turned off. The options can also be specified as arguments to an invocation of the shell. The current set of options may be found in .BR $\- . The return status is always zero unless an invalid option is encountered. .RE .TP \fBshift\fP [\fIn\fP] Rename positional parameters from \fIn\fP+1 .\|.\|.\& to .B $1 .B .\|.\|.. Parameters represented by the numbers \fB$#\fP down to \fB$#\fP\-\fIn\fP+1 are unset. .I n must be a non-negative number less than or equal to \fB$#\fP. If .I n is 0, no parameters are changed. If .I n is not given, it is assumed to be 1. If .I n is greater than \fB$#\fP, the positional parameters are not changed. The return status is greater than zero if .I n is greater than .B $# or less than zero; otherwise 0. .TP \fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP .\|.\|.] Toggle the values of settings controlling optional shell behavior. The settings can be either those listed below, or, if the .B \-o option is used, those available with the .B \-o option to the \fBset\fP builtin command. .IP With no options, or with the .B \-p option, display a list of all settable options, with an indication of whether or not each is set; if any \fIoptnames\fP are supplied, the output is restricted to those options. The \fB\-p\fP option displays output in a form that may be reused as input. .IP Other options have the following meanings: .RS .PD 0 .TP .B \-s Enable (set) each \fIoptname\fP. .TP .B \-u Disable (unset) each \fIoptname\fP. .TP .B \-q Suppresses normal output (quiet mode); the return status indicates whether the \fIoptname\fP is set or unset. If multiple \fIoptname\fP arguments are supplied with .BR \-q , the return status is zero if all \fIoptnames\fP are enabled; non-zero otherwise. .TP .B \-o Restricts the values of \fIoptname\fP to be those defined for the .B \-o option to the .B set builtin. .PD .PP If either .B \-s or .B \-u is used with no \fIoptname\fP arguments, .B shopt shows only those options which are set or unset, respectively. Unless otherwise noted, the \fBshopt\fP options are disabled (unset) by default. .PP The return status when listing options is zero if all \fIoptnames\fP are enabled, non-zero otherwise. When setting or unsetting options, the return status is zero unless an \fIoptname\fP is not a valid shell option. .PP The list of \fBshopt\fP options is: .PP .PD 0 .TP 8 .B array_expand_once If set, the shell suppresses multiple evaluation of associative and indexed array subscripts during arithmetic expression evaluation, while executing builtins that can perform variable assignments, and while executing builtins that perform array dereferencing. .TP 8 .B assoc_expand_once Deprecated; a synonym for \fBarray_expand_once\fP. .TP 8 .B autocd If set, a command name that is the name of a directory is executed as if it were the argument to the \fBcd\fP command. This option is only used by interactive shells. .TP 8 .B bash_source_fullpath If set, filenames added to the \fBBASH_SOURCE\fP array variable are converted to full pathnames (see \fBShell Variables\fP above). .TP 8 .B cdable_vars If set, an argument to the .B cd builtin command that is not a directory is assumed to be the name of a variable whose value is the directory to change to. .TP 8 .B cdspell If set, the .B cd command attempts to correct minor errors in the spelling of a directory component. Minor errors include transposed characters, a missing character, and one extra character. If \fBcd\fP corrects the directory name, it prints the corrected filename, and the command proceeds. This option is only used by interactive shells. .TP 8 .B checkhash If set, \fBbash\fP checks that a command found in the hash table exists before trying to execute it. If a hashed command no longer exists, \fBbash\fP performs a normal path search. .TP 8 .B checkjobs If set, \fBbash\fP lists the status of any stopped and running jobs before exiting an interactive shell. If any jobs are running, \fBbash\fP defers the exit until a second exit is attempted without an intervening command (see .SM .B "JOB CONTROL" .ie \n(zZ=1 in \fIbash\fP(1)). .el above). The shell always postpones exiting if any jobs are stopped. .TP 8 .B checkwinsize If set, \fBbash\fP checks the window size after each external (non-builtin) command and, if necessary, updates the values of .SM .B LINES and .SM .BR COLUMNS , using the file descriptor associated with the standard error if it is a terminal. This option is enabled by default. .TP 8 .B cmdhist If set, .B bash attempts to save all lines of a multiple-line command in the same history entry. This allows easy re-editing of multi-line commands. This option is enabled by default, but only has an effect if command history is enabled, as described .ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM .BR HISTORY . .PD 0 .TP 8 .B compat31 .TP 8 .B compat32 .TP 8 .B compat40 .TP 8 .B compat41 .TP 8 .B compat42 .TP 8 .B compat43 .TP 8 .B compat44 .PD These control aspects of the shell's compatibility mode (see .SM .B "SHELL COMPATIBILITY MODE" .ie \n(zZ=1 in \fIbash\fP(1)). .el below). .PD 0 .TP 8 .B complete_fullquote If set, .B bash quotes all shell metacharacters in filenames and directory names when performing completion. If not set, .B bash removes metacharacters such as the dollar sign from the set of characters that will be quoted in completed filenames when these metacharacters appear in shell variable references in words to be completed. This means that dollar signs in variable names that expand to directories will not be quoted; however, any dollar signs appearing in filenames will not be quoted, either. This is active only when bash is using backslashes to quote completed filenames. This variable is set by default, which is the default bash behavior in versions through 4.2. .TP 8 .B direxpand If set, .B bash replaces directory names with the results of word expansion when performing filename completion. This changes the contents of the \fBreadline\fP editing buffer. If not set, .B bash attempts to preserve what the user typed. .TP 8 .B dirspell If set, .B bash attempts spelling correction on directory names during word completion if the directory name initially supplied does not exist. .TP 8 .B dotglob If set, .B bash includes filenames beginning with a .Q .\& in the results of pathname expansion. The filenames .FN .\& and .FN ..\& must always be matched explicitly, even if .B dotglob is set. .TP 8 .B execfail If set, a non-interactive shell will not exit if it cannot execute the file specified as an argument to the .B exec builtin. An interactive shell does not exit if .B exec fails. .TP 8 .B expand_aliases If set, aliases are expanded as described .ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM .BR ALIASES . This option is enabled by default for interactive shells. .TP 8 .B extdebug If set at shell invocation, or in a shell startup file, arrange to execute the debugger profile before the shell starts, identical to the \fB\-\-debugger\fP option. If set after invocation, behavior intended for use by debuggers is enabled: .RS .TP .B 1. The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source file name and line number corresponding to each function name supplied as an argument. .TP .B 2. If the command run by the \fBDEBUG\fP trap returns a non-zero value, the next command is skipped and not executed. .TP .B 3. If the command run by the \fBDEBUG\fP trap returns a value of 2, and the shell is executing in a subroutine (a shell function or a shell script executed by the \fB.\fP or \fBsource\fP builtins), the shell simulates a call to \fBreturn\fP. .TP .B 4. .SM .B BASH_ARGC and .SM .B BASH_ARGV are updated as described in their descriptions .ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP .B 5. Function tracing is enabled: command substitution, shell functions, and subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the \fBDEBUG\fP and \fBRETURN\fP traps. .TP .B 6. Error tracing is enabled: command substitution, shell functions, and subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the \fBERR\fP trap. .RE .TP 8 .B extglob If set, enable the extended pattern matching features described .ie \n(zZ=1 in \fIbash\fP(1) .el above under \fBPathname Expansion\fP. .TP 8 .B extquote If set, \fB$\fP\*'\fIstring\fP\*' and \fB$\fP\*"\fIstring\fP\*" quoting is performed within \fB${\fP\fIparameter\fP\fB}\fP expansions enclosed in double quotes. This option is enabled by default. .TP 8 .B failglob If set, patterns which fail to match filenames during pathname expansion result in an expansion error. .TP 8 .B force_fignore If set, the suffixes specified by the .SM .B FIGNORE shell variable cause words to be ignored when performing word completion even if the ignored words are the only possible completions. See .B "Shell Variables" .ie \n(zZ=1 in \fIbash\fP(1) .el above for a description of .SM .BR FIGNORE . This option is enabled by default. .TP 8 .B globasciiranges If set, range expressions used in pattern matching bracket expressions (see .SM .B "Pattern Matching" .ie \n(zZ=1 in \fIbash\fP(1)) .el above) behave as if in the traditional C locale when performing comparisons. That is, pattern matching does not take the current locale's collating sequence into account, so .B b will not collate between .B A and .BR B , and upper-case and lower-case ASCII characters will collate together. .TP 8 .B globskipdots If set, pathname expansion will never match the filenames .FN .\& and .FN ..\& , even if the pattern begins with a .Q .\& . This option is enabled by default. .TP 8 .B globstar If set, the pattern \fB**\fP used in a pathname expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a \fB/\fP, only directories and subdirectories match. .TP 8 .B gnu_errfmt If set, shell error messages are written in the standard GNU error message format. .TP 8 .B histappend If set, the history list is appended to the file named by the value of the .SM .B HISTFILE variable when the shell exits, rather than overwriting the file. .TP 8 .B histreedit If set, and .B readline is being used, the user is given the opportunity to re-edit a failed history substitution. .TP 8 .B histverify If set, and .B readline is being used, the results of history substitution are not immediately passed to the shell parser. Instead, the resulting line is loaded into the \fBreadline\fP editing buffer, allowing further modification. .TP 8 .B hostcomplete If set, and .B readline is being used, \fBbash\fP will attempt to perform hostname completion when a word containing a \fB@\fP is being completed (see .B Completing under .SM .B READLINE .ie \n(zZ=1 in \fIbash\fP(1)). .el above). This is enabled by default. .TP 8 .B huponexit If set, \fBbash\fP will send .SM .B SIGHUP to all jobs when an interactive login shell exits. .TP 8 .B inherit_errexit If set, command substitution inherits the value of the \fBerrexit\fP option, instead of unsetting it in the subshell environment. This option is enabled when posix mode is enabled. .TP 8 .B interactive_comments In an interactive shell, a word beginning with \fB#\fP causes that word and all remaining characters on that line to be ignored, as in a non-interactive shell (see .SM .B COMMENTS .ie \n(zZ=1 in \fIbash\fP(1)). .el above). This option is enabled by default. .TP 8 .B lastpipe If set, and job control is not active, the shell runs the last command of a pipeline not executed in the background in the current shell environment. .TP 8 .B lithist If set, and the .B cmdhist option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators where possible. .TP 8 .B localvar_inherit If set, local variables inherit the value and attributes of a variable of the same name that exists at a previous scope before any new value is assigned. The nameref attribute is not inherited. .TP 8 .B localvar_unset If set, calling \fBunset\fP on local variables in previous function scopes marks them so subsequent lookups find them unset until that function returns. This is identical to the behavior of unsetting local variables at the current function scope. .TP 8 .B login_shell The shell sets this option if it is started as a login shell (see .SM .B "INVOCATION" .ie \n(zZ=1 in \fIbash\fP(1)). .el above). The value may not be changed. .TP 8 .B mailwarn If set, and a file that \fBbash\fP is checking for mail has been accessed since the last time it was checked, \fBbash\fP displays the message .Q "The mail in \fImailfile\fP has been read" . .TP 8 .B no_empty_cmd_completion If set, and .B readline is being used, .B bash does not search .SM .B PATH for possible completions when completion is attempted on an empty line. .TP 8 .B nocaseglob If set, .B bash matches filenames in a case\-insensitive fashion when performing pathname expansion (see .B "Pathname Expansion" .ie \n(zZ=1 in \fIbash\fP(1)). .el above). .TP 8 .B nocasematch If set, .B bash matches patterns in a case\-insensitive fashion when performing matching while executing \fBcase\fP or \fB[[\fP conditional commands, when performing pattern substitution word expansions, or when filtering possible completions as part of programmable completion. .TP 8 .B noexpand_translation If set, .B bash encloses the translated results of .BR $\*" .\|.\|.\& \*" quoting in single quotes instead of double quotes. If the string is not translated, this has no effect. .TP 8 .B nullglob If set, pathname expansion patterns which match no files (see .B "Pathname Expansion" .ie \n(zZ=1 in \fIbash\fP(1)) .el above) expand to nothing and are removed, rather than expanding to themselves. .TP 8 .B patsub_replacement If set, \fBbash\fP expands occurrences of \fB&\fP in the replacement string of pattern substitution to the text matched by the pattern, as described under \fBParameter Expansion\fP .ie \n(zZ=1 in \fIbash\fP(1). .el above. This option is enabled by default. .TP 8 .B progcomp If set, enable the programmable completion facilities (see \fBProgrammable Completion\fP .ie \n(zZ=1 in \fIbash\fP(1)). .el above). This option is enabled by default. .TP 8 .B progcomp_alias If set, and programmable completion is enabled, \fBbash\fP treats a command name that doesn't have any completions as a possible alias and attempts alias expansion. If it has an alias, \fBbash\fP attempts programmable completion using the command word resulting from the expanded alias. .TP 8 .B promptvars If set, prompt strings undergo parameter expansion, command substitution, arithmetic expansion, and quote removal after being expanded as described in .SM .B PROMPTING .ie \n(zZ=1 in \fIbash\fP(1). .el above. This option is enabled by default. .TP 8 .B restricted_shell The shell sets this option if it is started in restricted mode (see .SM .B "RESTRICTED SHELL" .ie \n(zZ=1 in \fIbash\fP(1)). .el below). The value may not be changed. This is not reset when the startup files are executed, allowing the startup files to discover whether or not a shell is restricted. .TP 8 .B shift_verbose If set, the .B shift builtin prints an error message when the shift count exceeds the number of positional parameters. .TP 8 .B sourcepath If set, the \fB.\fP (\fBsource\fP) builtin uses the value of .SM .B PATH to find the directory containing the file supplied as an argument when the \fB\-p\fP option is not supplied. This option is enabled by default. .TP 8 .B varredir_close If set, the shell automatically closes file descriptors assigned using the \fI{varname}\fP redirection syntax (see .SM .B REDIRECTION .ie \n(zZ=1 in \fIbash\fP(1)) .el above) instead of leaving them open when the command completes. .TP 8 .B xpg_echo If set, the \fBecho\fP builtin expands backslash-escape sequences by default. If the \fBposix\fP shell option is also enabled, \fBecho\fP does not interpret any options. .RE .PD .TP \fBsuspend\fP [\fB\-f\fP] Suspend the execution of this shell until it receives a .SM .B SIGCONT signal. A login shell, or a shell without job control enabled, cannot be suspended; the .B \-f option will override this and force the suspension. The return status is 0 unless the shell is a login shell or job control is not enabled and .B \-f is not supplied. .TP \fBtest\fP \fIexpr\fP .PD 0 .TP \fB[\fP \fIexpr\fP \fB]\fP .PD Return a status of 0 (true) or 1 (false) depending on the evaluation of the conditional expression .IR expr . Each operator and operand must be a separate argument. Expressions are composed of the primaries described .ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM .BR "CONDITIONAL EXPRESSIONS" . \fBtest\fP does not accept any options, nor does it accept and ignore an argument of \fB\-\-\fP as signifying the end of options. .IP Expressions may be combined using the following operators, listed in decreasing order of precedence. The evaluation depends on the number of arguments; see below. \fBtest\fP uses operator precedence when there are five or more arguments. .RS .PD 0 .TP .B ! \fIexpr\fP True if .I expr is false. .TP .B ( \fIexpr\fP ) Returns the value of \fIexpr\fP. This may be used to override normal operator precedence. .TP \fIexpr1\fP \-\fBa\fP \fIexpr2\fP True if both .I expr1 and .I expr2 are true. .TP \fIexpr1\fP \-\fBo\fP \fIexpr2\fP True if either .I expr1 or .I expr2 is true. .PD .PP \fBtest\fP and \fB[\fP evaluate conditional expressions using a set of rules based on the number of arguments. .PP .PD 0 .TP 0 arguments The expression is false. .TP 1 argument The expression is true if and only if the argument is not null. .TP 2 arguments If the first argument is \fB!\fP, the expression is true if and only if the second argument is null. If the first argument is one of the unary conditional operators listed .ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM .BR "CONDITIONAL EXPRESSIONS" , the expression is true if the unary test is true. If the first argument is not a valid unary conditional operator, the expression is false. .TP 3 arguments The following conditions are applied in the order listed. If the second argument is one of the binary conditional operators listed .ie \n(zZ=1 in \fIbash\fP(1) .el above under .SM .BR "CONDITIONAL EXPRESSIONS" , the result of the expression is the result of the binary test using the first and third arguments as operands. The \fB\-a\fP and \fB\-o\fP operators are considered binary operators when there are three arguments. If the first argument is \fB!\fP, the value is the negation of the two-argument test using the second and third arguments. If the first argument is exactly \fB(\fP and the third argument is exactly \fB)\fP, the result is the one-argument test of the second argument. Otherwise, the expression is false. .TP 4 arguments The following conditions are applied in the order listed. If the first argument is \fB!\fP, the result is the negation of the three-argument expression composed of the remaining arguments. If the first argument is exactly \fB(\fP and the fourth argument is exactly \fB)\fP, the result is the two-argument test of the second and third arguments. Otherwise, the expression is parsed and evaluated according to precedence using the rules listed above. .TP 5 or more arguments The expression is parsed and evaluated according to precedence using the rules listed above. .PD .PP When the shell is in posix mode, or if the expression is part of the \fB[[\fP command, the \fB<\fP and \fB>\fP operators sort using the current locale. If the shell is not in posix mode, the \fBtest\fP and \fB[\fP commands sort lexicographically using ASCII ordering. .PP The historical operator-precedence parsing with 4 or more arguments can lead to ambiguities when it encounters strings that look like primaries. The .SM POSIX standard has deprecated the \fB\-a\fP and \fB\-o\fP primaries and enclosing expressions within parentheses. Scripts should no longer use them. It's much more reliable to restrict test invocations to a single primary, and to replace uses of \fB\-a\fP and \fB\-o\fP with the shell's \fB&&\fP and \fB||\fP list operators. .RE .TP .B times Print the accumulated user and system times for the shell and for processes run from the shell. The return status is 0. .TP \fBtrap\fP [\fB\-lpP\fP] [[\fIaction\fP] \fIsigspec\fP .\|.\|.] The .I action is a command that is read and executed when the shell receives any of the signals .IR sigspec . If .I action is absent (and there is a single \fIsigspec\fP) or .BR \- , each specified \fIsigspec\fP is reset to the value it had when the shell was started. If .I action is the null string the signal specified by each .I sigspec is ignored by the shell and by the commands it invokes. .IP If no arguments are supplied, .B trap displays the actions associated with each trapped signal as a set of \fBtrap\fP commands that can be reused as shell input to restore the current signal dispositions. If .B \-p is given, and .I action is not present, then \fBtrap\fP displays the actions associated with each .I sigspec or, if none are supplied, for all trapped signals, as a set of \fBtrap\fP commands that can be reused as shell input to restore the current signal dispositions. The .B \-P option behaves similarly, but displays only the actions associated with each \fIsigspec\fP argument. .B \-P requires at least one \fIsigspec\fP argument. The \fB\-P\fP or \fB\-p\fP options may be used in a subshell environment (e.g., command substitution) and, as long as they are used before \fBtrap\fP is used to change a signal's handling, will display the state of its parent's traps. .IP The .B \-l option prints a list of signal names and their corresponding numbers. Each .I sigspec is either a signal name defined in <\fIsignal.h\fP>, or a signal number. Signal names are case insensitive and the .SM .B SIG prefix is optional. If \fB\-l\fP is supplied with no \fIsigspec\fP arguments, it prints a list of valid signal names. .IP If a .I sigspec is .SM .B EXIT (0), .I action is executed on exit from the shell. If a .I sigspec is .SM .BR DEBUG , .I action is executed before every \fIsimple command\fP, \fIfor\fP command, \fIcase\fP command, \fIselect\fP command, (( arithmetic command, [[ conditional command, arithmetic \fIfor\fP command, and before the first command executes in a shell function (see .SM .B "SHELL GRAMMAR" .ie \n(zZ=1 in \fIbash\fP(1)). .el above). Refer to the description of the \fBextdebug\fP shell option (see .B shopt .ie \n(zZ=1 in \fIbash\fP(1)) .el above) for details of its effect on the \fBDEBUG\fP trap. If a .I sigspec is .SM .BR RETURN , .I action is executed each time a shell function or a script executed with the \fB.\fP or \fBsource\fP builtins finishes executing. .IP If a .I sigspec is .SM .BR ERR , .I action is executed whenever a pipeline (which may consist of a single simple command), a list, or a compound command returns a non\-zero exit status, subject to the following conditions. The .SM .B ERR trap is not executed if the failed command is part of the command list immediately following a .B while or .B until reserved word, part of the test in an .I if statement, part of a command executed in a .B && or .B || list except the command following the final \fB&&\fP or \fB||\fP, any command in a pipeline but the last (subject to the state of the \fBpipefail\fP shell option), or if the command's return value is being inverted using .BR ! . These are the same conditions obeyed by the \fBerrexit\fP (\fB\-e\fP) option. .IP When the shell is not interactive, signals ignored upon entry to the shell cannot be trapped or reset. Interactive shells permit trapping signals ignored on entry. Trapped signals that are not being ignored are reset to their original values in a subshell or subshell environment when one is created. The return status is false if any .I sigspec is invalid; otherwise .B trap returns true. .TP \fBtrue\fP Does nothing, returns a 0 status. .TP \fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP .\|.\|.] Indicate how each .I name would be interpreted if used as a command name. .IP If the .B \-t option is used, .B type prints a string which is one of .IR alias , .IR keyword , .IR function , .IR builtin , or .I file if .I name is an alias, shell reserved word, function, builtin, or executable file, respectively. If the .I name is not found, \fBtype\fP prints nothing and returns a non-zero exit status. .IP If the .B \-p option is used, .B type either returns the pathname of the executable file that would be found by searching .B $PATH for .I name or nothing if .Q "type \-t name" would not return .IR file . The .B \-P option forces a .SM .B PATH search for each \fIname\fP, even if .Q "type \-t name" would not return .IR file . If \fIname\fP is present in the table of hashed commands, .B \-p and .B \-P print the hashed value, which is not necessarily the file that appears first in .SM .BR PATH . .IP If the .B \-a option is used, .B type prints all of the places that contain a command named .IR name . This includes aliases, reserved words, functions, and builtins, but the path search options (\fB\-p\fP and \fB\-P\fP) can be supplied to restrict the output to executable files. \fBtype\fP does not consult the table of hashed commands when using .B \-a with .BR \-p , and only performs a .SM .B PATH search for \fIname\fP. .IP The .B \-f option suppresses shell function lookup, as with the \fBcommand\fP builtin. .B type returns true if all of the arguments are found, false if any are not found. .TP \fBulimit\fP [\fB\-HS\fP] \fB\-a\fP .PD 0 .TP \fBulimit\fP [\fB\-HS\fP] [\fB\-bcdefiklmnpqrstuvxPRT\fP [\fIlimit\fP]] .PD Provides control over the resources available to the shell and to processes it starts, on systems that allow such control. .IP The \fB\-H\fP and \fB\-S\fP options specify whether the hard or soft limit is set for the given resource. A hard limit cannot be increased by a non-root user once it is set; a soft limit may be increased up to the value of the hard limit. If neither \fB\-H\fP nor \fB\-S\fP is specified, \fBulimit\fP sets both the soft and hard limits. .IP The value of .I limit can be a number in the unit specified for the resource or one of the special values .BR hard , .BR soft , or .BR unlimited , which stand for the current hard limit, the current soft limit, and no limit, respectively. If .I limit is omitted, \fBulimit\fP prints the current value of the soft limit of the resource, unless the \fB\-H\fP option is given. When more than one resource is specified, the limit name and unit, if appropriate, are printed before the value. Other options are interpreted as follows: .RS .PD 0 .TP .B \-a Report all current limits; no limits are set. .TP .B \-b The maximum socket buffer size. .TP .B \-c The maximum size of core files created. .TP .B \-d The maximum size of a process's data segment. .TP .B \-e The maximum scheduling priority (\c .Q nice ). .TP .B \-f The maximum size of files written by the shell and its children. .TP .B \-i The maximum number of pending signals. .TP .B \-k The maximum number of kqueues that may be allocated. .TP .B \-l The maximum size that may be locked into memory. .TP .B \-m The maximum resident set size (many systems do not honor this limit). .TP .B \-n The maximum number of open file descriptors (most systems do not allow this value to be set). .TP .B \-p The pipe size in 512-byte blocks (this may not be set). .TP .B \-q The maximum number of bytes in .SM POSIX message queues. .TP .B \-r The maximum real-time scheduling priority. .TP .B \-s The maximum stack size. .TP .B \-t The maximum amount of cpu time in seconds. .TP .B \-u The maximum number of processes available to a single user. .TP .B \-v The maximum amount of virtual memory available to the shell and, on some systems, to its children. .TP .B \-x The maximum number of file locks. .TP .B \-P The maximum number of pseudoterminals. .TP .B \-R The maximum time a real-time process can run before blocking, in microseconds. .TP .B \-T The maximum number of threads. .PD .PP If .I limit is supplied, and the .B \-a option is not used, \fIlimit\fP is the new value of the specified resource. If no option is supplied, then .B \-f is assumed. .PP Values are in 1024-byte increments, except for .BR \-t , which is in seconds; .BR \-R , which is in microseconds; .BR \-p , which is in units of 512-byte blocks; .BR \-P , .BR \-T , .BR \-b , .BR \-k , .BR \-n , and .BR \-u , which are unscaled values; and, when in posix mode, .B \-c and .BR \-f , which are in 512-byte increments. The return status is 0 unless an invalid option or argument is supplied, or an error occurs while setting a new limit. .RE .TP \fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP] Set the user file-creation mask to .IR mode . If .I mode begins with a digit, it is interpreted as an octal number; otherwise it is interpreted as a symbolic mode mask similar to that accepted by .IR chmod (1). If .I mode is omitted, \fBumask\fP prints the current value of the mask. The .B \-S option without a \fImode\fP argument prints the mask in a symbolic format; the default output is an octal number. If the .B \-p option is supplied, and .I mode is omitted, the output is in a form that may be reused as input. The return status is zero if the mode was successfully changed or if no \fImode\fP argument was supplied, and non-zero otherwise. .TP \fBunalias\fP [\-\fBa\fP] [\fIname\fP .\|.\|.] Remove each \fIname\fP from the list of defined aliases. If .B \-a is supplied, remove all alias definitions. The return value is true unless a supplied .I name is not a defined alias. .TP \fBunset\fP [\-\fBfv\fP] [\-\fBn\fP] [\fIname\fP .\|.\|.] For each .IR name , remove the corresponding variable or function. If the .B \-v option is given, each .I name refers to a shell variable, and that variable is removed. If .B \-f is specified, each .I name refers to a shell function, and the function definition is removed. If the .B \-n option is supplied, and \fIname\fP is a variable with the \fInameref\fP attribute, \fIname\fP will be unset rather than the variable it references. \fB\-n\fP has no effect if the \fB\-f\fP option is supplied. Read-only variables and functions may not be unset. When variables or functions are removed, they are also removed from the environment passed to subsequent commands. If no options are supplied, each \fIname\fP refers to a variable; if there is no variable by that name, a function with that name, if any, is unset. Some shell variables may not be unset. If any of .SM .BR BASH_ALIASES , .SM .BR BASH_ARGV0 , .SM .BR BASH_CMDS , .SM .BR BASH_COMMAND , .SM .BR BASH_SUBSHELL , .SM .BR BASHPID , .SM .BR COMP_WORDBREAKS , .SM .BR DIRSTACK , .SM .BR EPOCHREALTIME , .SM .BR EPOCHSECONDS , .SM .BR FUNCNAME , .SM .BR GROUPS , .SM .BR HISTCMD , .SM .BR LINENO , .SM .BR RANDOM , .SM .BR SECONDS , or .SM .B SRANDOM are unset, they lose their special properties, even if they are subsequently reset. The exit status is true unless a .I name is readonly or may not be unset. .TP \fBwait\fP [\fB\-fn\fP] [\fP\-p\fP \fIvarname\fP] [\fIid\fP .\|.\|.] Wait for each specified child process \fIid\fP and return the termination status of the last \fIid\fP. Each \fIid\fP may be a process ID \fIpid\fP or a job specification \fIjobspec\fP; if a jobspec is supplied, \fBwait\fP waits for all processes in the job. .IP If no options or \fIid\fPs are supplied, \fBwait\fP waits for all running background jobs and the last-executed process substitution, if its process id is the same as \fB$!\fP, and the return status is zero. .IP If the \fB\-n\fP option is supplied, \fBwait\fP waits for any one of the given \fIid\fPs or, if no \fIid\fPs are supplied, any job or process substitution, to complete and returns its exit status. If none of the supplied \fIid\fPs is a child of the shell, or if no \fIid\fPs are supplied and the shell has no unwaited-for children, the exit status is 127. .IP If the \fB\-p\fP option is supplied, \fBwait\fP assigns the process or job identifier of the job for which the exit status is returned to the variable \fIvarname\fP named by the option argument. The variable, which cannot be readonly, will be unset initially, before any assignment. This is useful only when used with the \fB\-n\fP option. .IP Supplying the \fB\-f\fP option, when job control is enabled, forces \fBwait\fP to wait for each \fIid\fP to terminate before returning its status, instead of returning when it changes status. .IP If none of the \fIid\fPs specify one of the shell's active child processes, the return status is 127. If \fBwait\fP is interrupted by a signal, any \fIvarname\fP will remain unset, and the return status will be greater than 128, as described under .B SIGNALS .ie \n(zZ=1 in \fIbash\fP(1). .el above. Otherwise, the return status is the exit status of the last \fIid\fP. .SH "SHELL COMPATIBILITY MODE" Bash-4.0 introduced the concept of a \fIshell compatibility level\fP, specified as a set of options to the shopt builtin (\c .BR compat31 , .BR compat32 , .BR compat40 , .BR compat41 , and so on). There is only one current compatibility level \(em each option is mutually exclusive. The compatibility level is intended to allow users to select behavior from previous versions that is incompatible with newer versions while they migrate scripts to use current features and behavior. It's intended to be a temporary solution. .PP This section does not mention behavior that is standard for a particular version (e.g., setting \fBcompat32\fP means that quoting the right hand side of the regexp matching operator quotes special regexp characters in the word, which is default behavior in bash-3.2 and subsequent versions). .PP If a user enables, say, \fBcompat32\fP, it may affect the behavior of other compatibility levels up to and including the current compatibility level. The idea is that each compatibility level controls behavior that changed in that version of \fBbash\fP, but that behavior may have been present in earlier versions. For instance, the change to use locale-based comparisons with the \fB[[\fP command came in bash-4.1, and earlier versions used ASCII-based comparisons, so enabling \fBcompat32\fP will enable ASCII-based comparisons as well. That granularity may not be sufficient for all uses, and as a result users should employ compatibility levels carefully. Read the documentation for a particular feature to find out the current behavior. .PP Bash-4.3 introduced a new shell variable: .SM .BR BASH_COMPAT . The value assigned to this variable (a decimal version number like 4.2, or an integer corresponding to the \fBcompat\fP\fINN\fP option, like 42) determines the compatibility level. .PP Starting with bash-4.4, \fBbash\fP began deprecating older compatibility levels. Eventually, the options will be removed in favor of .SM .BR BASH_COMPAT . .PP Bash-5.0 was the final version for which there was an individual shopt option for the previous version. .SM .B BASH_COMPAT is the only mechanism to control the compatibility level in versions newer than bash-5.0. .PP The following table describes the behavior changes controlled by each compatibility level setting. The \fBcompat\fP\fINN\fP tag is used as shorthand for setting the compatibility level to \fINN\fP using one of the following mechanisms. For versions prior to bash-5.0, the compatibility level may be set using the corresponding \fBcompat\fP\fINN\fP shopt option. For bash-4.3 and later versions, the .SM .B BASH_COMPAT variable is preferred, and it is required for bash-5.1 and later versions. .TP \fBcompat31\fP .PD 0 .RS .IP \(bu Quoting the rhs of the \fB[[\fP command's regexp matching operator (=\*~) has no special effect. .RE .PD .TP \fBcompat32\fP .PD 0 .RS .IP \(bu The \fB<\fP and \fB>\fP operators to the \fB[[\fP command do not consider the current locale when comparing strings; they use ASCII ordering. .RE .PD .TP \fBcompat40\fP .PD 0 .RS .IP \(bu The \fB<\fP and \fB>\fP operators to the \fB[[\fP command do not consider the current locale when comparing strings; they use ASCII ordering. \fBBash\fP versions prior to bash-4.1 use ASCII collation and .IR strcmp (3); bash-4.1 and later use the current locale's collation sequence and .IR strcoll (3). .RE .PD .TP \fBcompat41\fP .PD 0 .RS .IP \(bu In posix mode, \fBtime\fP may be followed by options and still be recognized as a reserved word (this is .SM POSIX interpretation 267). .IP \(bu In \fIposix\fP mode, the parser requires that an even number of single quotes occur in the \fIword\fP portion of a double-quoted parameter expansion and treats them specially, so that characters within the single quotes are considered quoted (this is .SM POSIX interpretation 221). .RE .PD .TP \fBcompat42\fP .PD 0 .RS .IP \(bu The replacement string in double-quoted pattern substitution does not undergo quote removal, as it does in versions after bash-4.2. .IP \(bu In posix mode, single quotes are considered special when expanding the \fIword\fP portion of a double-quoted parameter expansion and can be used to quote a closing brace or other special character (this is part of .SM POSIX interpretation 221); in later versions, single quotes are not special within double-quoted word expansions. .RE .PD .TP \fBcompat43\fP .PD 0 .RS .IP \(bu Word expansion errors are considered non-fatal errors that cause the current command to fail, even in posix mode (the default behavior is to make them fatal errors that cause the shell to exit). .IP \(bu When executing a shell function, the loop state (while/until/etc.) is not reset, so \fBbreak\fP or \fBcontinue\fP in that function will break or continue loops in the calling context. Bash-4.4 and later reset the loop state to prevent this. .RE .PD .TP \fBcompat44\fP .PD 0 .RS .IP \(bu The shell sets up the values used by .SM .B BASH_ARGV and .SM .B BASH_ARGC so they can expand to the shell's positional parameters even if extended debugging mode is not enabled. .IP \(bu A subshell inherits loops from its parent context, so \fBbreak\fP or \fBcontinue\fP will cause the subshell to exit. Bash-5.0 and later reset the loop state to prevent the exit .IP \(bu Variable assignments preceding builtins like \fBexport\fP and \fBreadonly\fP that set attributes continue to affect variables with the same name in the calling environment even if the shell is not in posix mode. .RE .PD .TP \fBcompat50\fP .PD 0 .RS .IP \(bu Bash-5.1 changed the way .SM .B $RANDOM is generated to introduce slightly more randomness. If the shell compatibility level is set to 50 or lower, it reverts to the method from bash-5.0 and previous versions, so seeding the random number generator by assigning a value to .SM .B RANDOM will produce the same sequence as in bash-5.0. .IP \(bu If the command hash table is empty, bash versions prior to bash-5.1 printed an informational message to that effect, even when producing output that can be reused as input. Bash-5.1 suppresses that message when the \fB\-l\fP option is supplied. .RE .PD .TP \fBcompat51\fP .PD 0 .RS .IP \(bu The \fBunset\fP builtin treats attempts to unset array subscripts \fB@\fP and \fB*\fP differently depending on whether the array is indexed or associative, and differently than in previous versions. .IP \(bu Arithmetic commands ( .BR (( .\|.\|.\& )) ) and the expressions in an arithmetic for statement can be expanded more than once. .IP \(bu Expressions used as arguments to arithmetic operators in the \fB[[\fP conditional command can be expanded more than once. .IP \(bu The expressions in substring parameter brace expansion can be expanded more than once. .IP \(bu The expressions in the .BR $(( .\|.\|.\& )) word expansion can be expanded more than once. .IP \(bu Arithmetic expressions used as indexed array subscripts can be expanded more than once. .IP \(bu \fBtest \-v\fP, when given an argument of \fBA[@]\fP, where \fBA\fP is an existing associative array, will return true if the array has any set elements. Bash-5.2 will look for and report on a key named \fB@\fP. .IP \(bu The ${\fIparameter\fP\fB[:]=\fP\fIvalue\fP} word expansion will return \fIvalue\fP, before any variable-specific transformations have been performed (e.g., converting to lowercase). Bash-5.2 will return the final value assigned to the variable. .IP \(bu Parsing command substitutions will behave as if extended globbing (see the description of the .B shopt builtin above) is enabled, so that parsing a command substitution containing an extglob pattern (say, as part of a shell function) will not fail. This assumes the intent is to enable extglob before the command is executed and word expansions are performed. It will fail at word expansion time if extglob hasn't been enabled by the time the command is executed. .RE .PD .TP \fBcompat52\fP .PD 0 .RS .IP \(bu The \fBtest\fP builtin uses its historical algorithm to parse parenthesized subexpressions when given five or more arguments. .IP \(bu If the \fB\-p\fP or \fB\-P\fP option is supplied to the \fBbind\fP builtin, \fBbind\fP treats any arguments remaining after option processing as bindable command names, and displays any key sequences bound to those commands, instead of treating the arguments as key sequences to bind. .RE .PD .\" bash_builtins .zY .lf 23 ./builtins.1 .SH SEE ALSO bash(1), sh(1)