BASH(1) BASH(1) NNAAMMEE bash - GNU Bourne-Again SHell SSYYNNOOPPSSIISS bbaasshh [options] [file] CCOOPPYYRRIIGGHHTT Bash is Copyright (C) 1989-2004 by the Free Software Foundation, Inc. DDEESSCCRRIIPPTTIIOONN BBaasshh is an sshh-compatible command language interpreter that executes commands read from the standard input or from a file. BBaasshh also incor- porates useful features from the _K_o_r_n and _C shells (kksshh and ccsshh). BBaasshh is intended to be a conformant implementation of the IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2). OOPPTTIIOONNSS In addition to the single-character shell options documented in the description of the sseett builtin command, bbaasshh interprets the following options when it is invoked: --cc _s_t_r_i_n_g If the --cc option is present, then commands are read from _s_t_r_i_n_g. If there are arguments after the _s_t_r_i_n_g, they are assigned to the positional parameters, starting with $$00. --ii If the --ii option is present, the shell is _i_n_t_e_r_a_c_t_i_v_e. --ll Make bbaasshh act as if it had been invoked as a login shell (see IINNVVOOCCAATTIIOONN below). --rr If the --rr option is present, the shell becomes _r_e_s_t_r_i_c_t_e_d (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). --ss If the --ss option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set when invoking an interactive shell. --DD A list of all double-quoted strings preceded by $$ is printed on the standard ouput. These are the strings that are sub- ject to language translation when the current locale is not CC or PPOOSSIIXX. This implies the --nn option; no commands will be executed. [[--++]]OO [[_s_h_o_p_t___o_p_t_i_o_n]] _s_h_o_p_t___o_p_t_i_o_n is one of the shell options accepted by the sshhoopptt builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). If _s_h_o_p_t___o_p_t_i_o_n is present, --OO sets the value of that option; ++OO unsets it. If _s_h_o_p_t___o_p_t_i_o_n is not supplied, the names and values of the shell options accepted by sshhoopptt are printed on the standard output. If the invocation option is ++OO, the output is displayed in a format that may be reused as input. ---- A ---- signals the end of options and disables further option processing. Any arguments after the ---- are treated as file- names and arguments. An argument of -- is equivalent to ----. BBaasshh also interprets a number of multi-character options. These options must appear on the command line before the single-character options to be recognized. ----ddeebbuuggggeerr Arrange for the debugger profile to be executed before the shell starts. Turns on extended debugging mode (see the description of the eexxttddeebbuugg option to the sshhoopptt builtin below) and shell function tracing (see the description of the --oo ffuunnccttrraaccee option to the sseett builtin below). ----dduummpp--ppoo--ssttrriinnggss Equivalent to --DD, but the output is in the GNU _g_e_t_t_e_x_t ppoo (portable object) file format. ----dduummpp--ssttrriinnggss Equivalent to --DD. ----hheellpp Display a usage message on standard output and exit success- fully. ----iinniitt--ffiillee _f_i_l_e ----rrccffiillee _f_i_l_e Execute commands from _f_i_l_e instead of the standard personal ini- tialization file _~_/_._b_a_s_h_r_c if the shell is interactive (see IINNVVOOCCAATTIIOONN below). ----llooggiinn Equivalent to --ll. ----nnooeeddiittiinngg Do not use the GNU rreeaaddlliinnee library to read command lines when the shell is interactive. ----nnoopprrooffiillee Do not read either the system-wide startup file _/_e_t_c_/_p_r_o_f_i_l_e or any of the personal initialization files _~_/_._b_a_s_h___p_r_o_f_i_l_e, _~_/_._b_a_s_h___l_o_g_i_n, or _~_/_._p_r_o_f_i_l_e. By default, bbaasshh reads these files when it is invoked as a login shell (see IINNVVOOCCAATTIIOONN below). ----nnoorrcc Do not read and execute the personal initialization file _~_/_._b_a_s_h_r_c if the shell is interactive. This option is on by default if the shell is invoked as sshh. ----ppoossiixx Change the behavior of bbaasshh where the default operation differs from the POSIX 1003.2 standard to match the standard (_p_o_s_i_x _m_o_d_e). ----rreessttrriicctteedd The shell becomes restricted (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). ----vveerrbboossee Equivalent to --vv. ----vveerrssiioonn Show version information for this instance of bbaasshh on the stan- dard output and exit successfully. AARRGGUUMMEENNTTSS If arguments remain after option processing, and neither the --cc nor the --ss option has been supplied, the first argument is assumed to be the name of a file containing shell commands. If bbaasshh is invoked in this fashion, $$00 is set to the name of the file, and the positional parame- ters are set to the remaining arguments. BBaasshh reads and executes com- mands from this file, then exits. BBaasshh's exit status is the exit sta- tus of the last command executed in the script. If no commands are executed, the exit status is 0. An attempt is first made to open the file in the current directory, and, if no file is found, then the shell searches the directories in PPAATTHH for the script. IINNVVOOCCAATTIIOONN A _l_o_g_i_n _s_h_e_l_l is one whose first character of argument zero is a --, or one started with the ----llooggiinn option. An _i_n_t_e_r_a_c_t_i_v_e shell is one started without non-option arguments and without the --cc option whose standard input and error are both connected to terminals (as determined by _i_s_a_t_t_y(3)), or one started with the --ii option. PPSS11 is set and $$-- includes ii if bbaasshh is interactive, allowing a shell script or a startup file to test this state. The following paragraphs describe how bbaasshh executes its startup files. If any of the files exist but cannot be read, bbaasshh reports an error. Tildes are expanded in file names as described below under TTiillddee EExxppaannssiioonn in the EEXXPPAANNSSIIOONN section. When bbaasshh is invoked as an interactive login shell, or as a non-inter- active shell with the ----llooggiinn option, it first reads and executes com- mands from the file _/_e_t_c_/_p_r_o_f_i_l_e, if that file exists. After reading that file, it looks for _~_/_._b_a_s_h___p_r_o_f_i_l_e, _~_/_._b_a_s_h___l_o_g_i_n, and _~_/_._p_r_o_f_i_l_e, in that order, and reads and executes commands from the first one that exists and is readable. The ----nnoopprrooffiillee option may be used when the shell is started to inhibit this behavior. When a login shell exits, bbaasshh reads and executes commands from the file _~_/_._b_a_s_h___l_o_g_o_u_t, if it exists. When an interactive shell that is not a login shell is started, bbaasshh reads and executes commands from _~_/_._b_a_s_h_r_c, if that file exists. This may be inhibited by using the ----nnoorrcc option. The ----rrccffiillee _f_i_l_e option will force bbaasshh to read and execute commands from _f_i_l_e instead of _~_/_._b_a_s_h_r_c. When bbaasshh is started non-interactively, to run a shell script, for example, it looks for the variable BBAASSHH__EENNVV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. BBaasshh behaves as if the following com- mand were executed: if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi but the value of the PPAATTHH variable is not used to search for the file name. If bbaasshh is invoked with the name sshh, it tries to mimic the startup behavior of historical versions of sshh as closely as possible, while conforming to the POSIX standard as well. When invoked as an interac- tive login shell, or a non-interactive shell with the ----llooggiinn option, it first attempts to read and execute commands from _/_e_t_c_/_p_r_o_f_i_l_e and _~_/_._p_r_o_f_i_l_e, in that order. The ----nnoopprrooffiillee option may be used to inhibit this behavior. When invoked as an interactive shell with the name sshh, bbaasshh looks for the variable EENNVV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute. Since a shell invoked as sshh does not attempt to read and exe- cute commands from any other startup files, the ----rrccffiillee option has no effect. A non-interactive shell invoked with the name sshh does not attempt to read any other startup files. When invoked as sshh, bbaasshh enters _p_o_s_i_x mode after the startup files are read. When bbaasshh is started in _p_o_s_i_x mode, as with the ----ppoossiixx command line option, it follows the POSIX standard for startup files. In this mode, interactive shells expand the EENNVV variable and commands are read and executed from the file whose name is the expanded value. No other startup files are read. BBaasshh attempts to determine when it is being run by the remote shell daemon, usually _r_s_h_d. If bbaasshh determines it is being run by _r_s_h_d, it reads and executes commands from _~_/_._b_a_s_h_r_c, if that file exists and is readable. It will not do this if invoked as sshh. The ----nnoorrcc option may be used to inhibit this behavior, and the ----rrccffiillee option may be used to force another file to be read, but _r_s_h_d does not generally invoke the shell with those options or allow them to be specified. If the shell is started with the effective user (group) id not equal to the real user (group) id, and the --pp option is not supplied, no startup files are read, shell functions are not inherited from the environment, the SSHHEELLLLOOPPTTSS variable, if it appears in the environment, is ignored, and the effective user id is set to the real user id. If the --pp option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset. DDEEFFIINNIITTIIOONNSS The following definitions are used throughout the rest of this docu- ment. bbllaannkk A space or tab. wwoorrdd A sequence of characters considered as a single unit by the shell. Also known as a ttookkeenn. nnaammee A _w_o_r_d consisting only of alphanumeric characters and under- scores, and beginning with an alphabetic character or an under- score. Also referred to as an iiddeennttiiffiieerr. mmeettaacchhaarraacctteerr A character that, when unquoted, separates words. One of the following: || && ;; (( )) << >> ssppaaccee ttaabb ccoonnttrrooll ooppeerraattoorr A _t_o_k_e_n that performs a control function. It is one of the fol- lowing symbols: |||| && &&&& ;; ;;;; (( )) || <> RREESSEERRVVEEDD WWOORRDDSS _R_e_s_e_r_v_e_d _w_o_r_d_s are words that have a special meaning to the shell. The following words are recognized as reserved when unquoted and either the first word of a simple command (see SSHHEELLLL GGRRAAMMMMAARR below) or the third word of a ccaassee or ffoorr command: !! ccaassee ddoo ddoonnee eelliiff eellssee eessaacc ffii ffoorr ffuunnccttiioonn iiff iinn sseelleecctt tthheenn uunnttiill wwhhiillee {{ }} ttiimmee [[[[ ]]]] SSHHEELLLL GGRRAAMMMMAARR SSiimmppllee CCoommmmaannddss A _s_i_m_p_l_e _c_o_m_m_a_n_d is a sequence of optional variable assignments fol- lowed by bbllaannkk-separated words and redirections, and terminated by a _c_o_n_t_r_o_l _o_p_e_r_a_t_o_r. The first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as arguments to the invoked command. The return value of a _s_i_m_p_l_e _c_o_m_m_a_n_d is its exit status, or 128+_n if the command is terminated by signal _n. PPiippeelliinneess A _p_i_p_e_l_i_n_e is a sequence of one or more commands separated by the char- acter ||. The format for a pipeline is: [ttiimmee [--pp]] [ ! ] _c_o_m_m_a_n_d [ || _c_o_m_m_a_n_d_2 ... ] The standard output of _c_o_m_m_a_n_d is connected via a pipe to the standard input of _c_o_m_m_a_n_d_2. This connection is performed before any redirec- tions specified by the command (see RREEDDIIRREECCTTIIOONN below). The return status of a pipeline is the exit status of the last command, unless the ppiippeeffaaiill option is enabled. If ppiippeeffaaiill is enabled, the pipeline's return status is the value of the last (rightmost) command to exit with a non-zero status, or zero if all commands exit success- fully. If the reserved word !! precedes a pipeline, the exit status of that pipeline is the logical negation of the exit status as described above. The shell waits for all commands in the pipeline to terminate before returning a value. If the ttiimmee reserved word precedes a pipeline, the elapsed as well as user and system time consumed by its execution are reported when the pipeline terminates. The --pp option changes the output format to that specified by POSIX. The TTIIMMEEFFOORRMMAATT variable may be set to a format string that specifies how the timing information should be displayed; see the description of TTIIMMEEFFOORRMMAATT under SShheellll VVaarriiaabblleess below. Each command in a pipeline is executed as a separate process (i.e., in a subshell). LLiissttss A _l_i_s_t is a sequence of one or more pipelines separated by one of the operators ;;, &&, &&&&, or ||||, and optionally terminated by one of ;;, &&, or <>. Of these list operators, &&&& and |||| have equal precedence, followed by ;; and &&,, which have equal precedence. A sequence of one or more newlines may appear in a _l_i_s_t instead of a semicolon to delimit commands. If a command is terminated by the control operator &&, the shell exe- cutes the command in the _b_a_c_k_g_r_o_u_n_d in a subshell. The shell does not wait for the command to finish, and the return status is 0. Commands separated by a ;; are executed sequentially; the shell waits for each command to terminate in turn. The return status is the exit status of the last command executed. The control operators &&&& and |||| denote AND lists and OR lists, respec- tively. An AND list has the form _c_o_m_m_a_n_d_1 &&&& _c_o_m_m_a_n_d_2 _c_o_m_m_a_n_d_2 is executed if, and only if, _c_o_m_m_a_n_d_1 returns an exit status of zero. An OR list has the form _c_o_m_m_a_n_d_1 |||| _c_o_m_m_a_n_d_2 _c_o_m_m_a_n_d_2 is executed if and only if _c_o_m_m_a_n_d_1 returns a non-zero exit status. The return status of AND and OR lists is the exit status of the last command executed in the list. CCoommppoouunndd CCoommmmaannddss A _c_o_m_p_o_u_n_d _c_o_m_m_a_n_d is one of the following: (_l_i_s_t) _l_i_s_t is executed in a subshell environment (see CCOOMMMMAANNDD EEXXEECCUU-- TTIIOONN EENNVVIIRROONNMMEENNTT below). Variable assignments and builtin com- mands that affect the shell's environment do not remain in effect after the command completes. The return status is the exit status of _l_i_s_t. { _l_i_s_t; } _l_i_s_t is simply executed in the current shell environment. _l_i_s_t must be terminated with a newline or semicolon. This is known as a _g_r_o_u_p _c_o_m_m_a_n_d. The return status is the exit status of _l_i_s_t. Note that unlike the metacharacters (( and )), {{ and }} are _r_e_s_e_r_v_e_d _w_o_r_d_s and must occur where a reserved word is permitted to be recognized. Since they do not cause a word break, they must be separated from _l_i_s_t by whitespace. ((_e_x_p_r_e_s_s_i_o_n)) The _e_x_p_r_e_s_s_i_o_n is evaluated according to the rules described below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. If the value of the expres- sion is non-zero, the return status is 0; otherwise the return status is 1. This is exactly equivalent to lleett ""_e_x_p_r_e_s_s_i_o_n"". [[[[ _e_x_p_r_e_s_s_i_o_n ]]]] Return a status of 0 or 1 depending on the evaluation of the conditional expression _e_x_p_r_e_s_s_i_o_n. Expressions are composed of the primaries described below under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS. Word splitting and pathname expansion are not performed on the words between the [[[[ and ]]]]; tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution, and quote removal are performed. Condi- tional operators such as --ff must be unquoted to be recognized as primaries. When the ==== and !!== operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below under PPaatttteerrnn MMaattcchhiinngg. The return value is 0 if the string matches or does not match the pattern, respectively, and 1 otherwise. Any part of the pattern may be quoted to force it to be matched as a string. An additional binary operator, ==~~, is available, with the same precedence as ==== and !!==. When it is used, the string to the right of the operator is considered an extended regular expres- sion and matched accordingly (as in _r_e_g_e_x(3)). The return value is 0 if the string matches the pattern, and 1 otherwise. If the regular expression is syntactically incorrect, the conditional expression's return value is 2. If the shell option nnooccaasseegglloobb is enabled, the match is performed without regard to the case of alphabetic characters. Substrings matched by parenthesized subexpressions within the regular expression are saved in the array variable BBAASSHH__RREEMMAATTCCHH. The element of BBAASSHH__RREEMMAATTCCHH with index 0 is the portion of the string matching the entire regular expression. The element of BBAASSHH__RREEMMAATTCCHH with index _n is the portion of the string matching the _nth parenthesized subexpres- sion. Expressions may be combined using the following operators, listed in decreasing order of precedence: (( _e_x_p_r_e_s_s_i_o_n )) Returns the value of _e_x_p_r_e_s_s_i_o_n. This may be used to override the normal precedence of operators. !! _e_x_p_r_e_s_s_i_o_n True if _e_x_p_r_e_s_s_i_o_n is false. _e_x_p_r_e_s_s_i_o_n_1 &&&& _e_x_p_r_e_s_s_i_o_n_2 True if both _e_x_p_r_e_s_s_i_o_n_1 and _e_x_p_r_e_s_s_i_o_n_2 are true. _e_x_p_r_e_s_s_i_o_n_1 |||| _e_x_p_r_e_s_s_i_o_n_2 True if either _e_x_p_r_e_s_s_i_o_n_1 or _e_x_p_r_e_s_s_i_o_n_2 is true. The &&&& and |||| operators do not evaluate _e_x_p_r_e_s_s_i_o_n_2 if the value of _e_x_p_r_e_s_s_i_o_n_1 is sufficient to determine the return value of the entire conditional expression. ffoorr _n_a_m_e [ iinn _w_o_r_d ] ; ddoo _l_i_s_t ; ddoonnee The list of words following iinn is expanded, generating a list of items. The variable _n_a_m_e is set to each element of this list in turn, and _l_i_s_t is executed each time. If the iinn _w_o_r_d is omit- ted, the ffoorr command executes _l_i_s_t once for each positional parameter that is set (see PPAARRAAMMEETTEERRSS below). The return status is the exit status of the last command that executes. If the expansion of the items following iinn results in an empty list, no commands are executed, and the return status is 0. ffoorr (( _e_x_p_r_1 ; _e_x_p_r_2 ; _e_x_p_r_3 )) ; ddoo _l_i_s_t ; ddoonnee First, the arithmetic expression _e_x_p_r_1 is evaluated according to the rules described below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. The arithmetic expression _e_x_p_r_2 is then evaluated repeatedly until it evaluates to zero. Each time _e_x_p_r_2 evaluates to a non-zero value, _l_i_s_t is executed and the arithmetic expression _e_x_p_r_3 is evaluated. If any expression is omitted, it behaves as if it evaluates to 1. The return value is the exit status of the last command in _l_i_s_t that is executed, or false if any of the expres- sions is invalid. sseelleecctt _n_a_m_e [ iinn _w_o_r_d ] ; ddoo _l_i_s_t ; ddoonnee The list of words following iinn is expanded, generating a list of items. The set of expanded words is printed on the standard error, each preceded by a number. If the iinn _w_o_r_d is omitted, the positional parameters are printed (see PPAARRAAMMEETTEERRSS below). The PPSS33 prompt is then displayed and a line read from the stan- dard input. If the line consists of a number corresponding to one of the displayed words, then the value of _n_a_m_e is set to that word. If the line is empty, the words and prompt are displayed again. If EOF is read, the command completes. Any other value read causes _n_a_m_e to be set to null. The line read is saved in the variable RREEPPLLYY. The _l_i_s_t is executed after each selection until a bbrreeaakk command is executed. The exit status of sseelleecctt is the exit status of the last command executed in _l_i_s_t, or zero if no commands were executed. ccaassee _w_o_r_d iinn [ [(] _p_a_t_t_e_r_n [ || _p_a_t_t_e_r_n ] ... ) _l_i_s_t ;; ] ... eessaacc A ccaassee command first expands _w_o_r_d, and tries to match it against each _p_a_t_t_e_r_n in turn, using the same matching rules as for path- name expansion (see PPaatthhnnaammee EExxppaannssiioonn below). When a match is found, the corresponding _l_i_s_t is executed. After the first match, no subsequent matches are attempted. The exit status is zero if no pattern matches. Otherwise, it is the exit status of the last command executed in _l_i_s_t. iiff _l_i_s_t; tthheenn _l_i_s_t_; [ eelliiff _l_i_s_t; tthheenn _l_i_s_t; ] ... [ eellssee _l_i_s_t; ] ffii The iiff _l_i_s_t is executed. If its exit status is zero, the tthheenn _l_i_s_t is executed. Otherwise, each eelliiff _l_i_s_t is executed in turn, and if its exit status is zero, the corresponding tthheenn _l_i_s_t is executed and the command completes. Otherwise, the eellssee _l_i_s_t is executed, if present. The exit status is the exit sta- tus of the last command executed, or zero if no condition tested true. wwhhiillee _l_i_s_t; ddoo _l_i_s_t; ddoonnee uunnttiill _l_i_s_t; ddoo _l_i_s_t; ddoonnee The wwhhiillee command continuously executes the ddoo _l_i_s_t as long as the last command in _l_i_s_t returns an exit status of zero. The uunnttiill command is identical to the wwhhiillee command, except that the test is negated; the ddoo _l_i_s_t is executed as long as the last command in _l_i_s_t returns a non-zero exit status. The exit status of the wwhhiillee and uunnttiill commands is the exit status of the last ddoo _l_i_s_t command executed, or zero if none was executed. SShheellll FFuunnccttiioonn DDeeffiinniittiioonnss A shell function is an object that is called like a simple command and executes a compound command with a new set of positional parameters. Shell functions are declared as follows: [ ffuunnccttiioonn ] _n_a_m_e () _c_o_m_p_o_u_n_d_-_c_o_m_m_a_n_d [_r_e_d_i_r_e_c_t_i_o_n] This defines a function named _n_a_m_e. The reserved word ffuunnccttiioonn is optional. If the ffuunnccttiioonn reserved word is supplied, the parentheses are optional. The _b_o_d_y of the function is the com- pound command _c_o_m_p_o_u_n_d_-_c_o_m_m_a_n_d (see CCoommppoouunndd CCoommmmaannddss above). That command is usually a _l_i_s_t of commands between { and }, but may be any command listed under CCoommppoouunndd CCoommmmaannddss above. _c_o_m_- _p_o_u_n_d_-_c_o_m_m_a_n_d is executed whenever _n_a_m_e is specified as the name of a simple command. Any redirections (see RREEDDIIRREECCTTIIOONN below) specified when a function is defined are performed when the function is executed. The exit status of a function definition is zero unless a syntax error occurs or a readonly function with the same name already exists. When executed, the exit status of a function is the exit status of the last command executed in the body. (See FFUUNNCCTTIIOONNSS below.) CCOOMMMMEENNTTSS In a non-interactive shell, or an interactive shell in which the iinntteerr-- aaccttiivvee__ccoommmmeennttss option to the sshhoopptt builtin is enabled (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below), a word beginning with ## causes that word and all remaining characters on that line to be ignored. An interactive shell without the iinntteerraaccttiivvee__ccoommmmeennttss option enabled does not allow comments. The iinntteerraaccttiivvee__ccoommmmeennttss option is on by default in interac- tive shells. QQUUOOTTIINNGG _Q_u_o_t_i_n_g is used to remove the special meaning of certain characters or words to the shell. Quoting can be used to disable special treatment for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion. Each of the _m_e_t_a_c_h_a_r_a_c_t_e_r_s listed above under DDEEFFIINNIITTIIOONNSS has special meaning to the shell and must be quoted if it is to represent itself. When the command history expansion facilities are being used, the _h_i_s_- _t_o_r_y _e_x_p_a_n_s_i_o_n character, usually !!, must be quoted to prevent history expansion. There are three quoting mechanisms: the _e_s_c_a_p_e _c_h_a_r_a_c_t_e_r, single quotes, and double quotes. A non-quoted backslash (\\) is the _e_s_c_a_p_e _c_h_a_r_a_c_t_e_r. It preserves the literal value of the next character that follows, with the exception of . If a \\ pair appears, and the backslash is not itself quoted, the \\ is treated as a line continuation (that is, it is removed from the input stream and effectively ignored). Enclosing characters in single quotes preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash. Enclosing characters in double quotes preserves the literal value of all characters within the quotes, with the exception of $$, ``, and \\. The characters $$ and `` retain their special meaning within double quotes. The backslash retains its special meaning only when followed by one of the following characters: $$, ``, "", \\, or <>. A double quote may be quoted within double quotes by preceding it with a back- slash. When command history is being used, the double quote may not be used to quote the history expansion character. The special parameters ** and @@ have special meaning when in double quotes (see PPAARRAAMMEETTEERRSS below). Words of the form $$'_s_t_r_i_n_g' are treated specially. The word expands to _s_t_r_i_n_g, with backslash-escaped characters replaced as specifed by the ANSI C standard. Backslash escape sequences, if present, are decoded as follows: \\aa alert (bell) \\bb backspace \\ee an escape character \\ff form feed \\nn new line \\rr carriage return \\tt horizontal tab \\vv vertical tab \\\\ backslash \\'' single quote \\_n_n_n the eight-bit character whose value is the octal value _n_n_n (one to three digits) \\xx_H_H the eight-bit character whose value is the hexadecimal value _H_H (one or two hex digits) \\cc_x a control-_x character The expanded result is single-quoted, as if the dollar sign had not been present. A double-quoted string preceded by a dollar sign ($$) will cause the string to be translated according to the current locale. If the cur- rent locale is CC or PPOOSSIIXX, the dollar sign is ignored. If the string is translated and replaced, the replacement is double-quoted. PPAARRAAMMEETTEERRSS A _p_a_r_a_m_e_t_e_r is an entity that stores values. It can be a _n_a_m_e, a num- ber, or one of the special characters listed below under SSppeecciiaall PPaarraamm-- eetteerrss. A _v_a_r_i_a_b_l_e is a parameter denoted by a _n_a_m_e. A variable has a _v_a_l_u_e and zero or more _a_t_t_r_i_b_u_t_e_s. Attributes are assigned using the ddeeccllaarree builtin command (see ddeeccllaarree below in SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS). A parameter is set if it has been assigned a value. The null string is a valid value. Once a variable is set, it may be unset only by using the uunnsseett builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). A _v_a_r_i_a_b_l_e may be assigned to by a statement of the form _n_a_m_e=[_v_a_l_u_e] If _v_a_l_u_e is not given, the variable is assigned the null string. All _v_a_l_u_e_s undergo tilde expansion, parameter and variable expansion, com- mand substitution, arithmetic expansion, and quote removal (see EEXXPPAANN-- SSIIOONN below). If the variable has its iinntteeggeerr attribute set, then _v_a_l_u_e is evaluated as an arithmetic expression even if the $((...)) expansion is not used (see AArriitthhmmeettiicc EExxppaannssiioonn below). Word splitting is not performed, with the exception of ""$$@@"" as explained below under SSppeecciiaall PPaarraammeetteerrss. Pathname expansion is not performed. Assignment state- ments may also appear as arguments to the aalliiaass, ddeeccllaarree, ttyyppeesseett, eexxppoorrtt, rreeaaddoonnllyy, and llooccaall builtin commands. PPoossiittiioonnaall PPaarraammeetteerrss A _p_o_s_i_t_i_o_n_a_l _p_a_r_a_m_e_t_e_r is a parameter denoted by one or more digits, other than the single digit 0. Positional parameters are assigned from the shell's arguments when it is invoked, and may be reassigned using the sseett builtin command. Positional parameters may not be assigned to with assignment statements. The positional parameters are temporarily replaced when a shell function is executed (see FFUUNNCCTTIIOONNSS below). When a positional parameter consisting of more than a single digit is expanded, it must be enclosed in braces (see EEXXPPAANNSSIIOONN below). SSppeecciiaall PPaarraammeetteerrss The shell treats several parameters specially. These parameters may only be referenced; assignment to them is not allowed. ** Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, it expands to a sin- gle word with the value of each parameter separated by the first character of the IIFFSS special variable. That is, "$$**" is equiva- lent to "$$11_c$$22_c......", where _c is the first character of the value of the IIFFSS variable. If IIFFSS is unset, the parameters are sepa- rated by spaces. If IIFFSS is null, the parameters are joined without intervening separators. @@ Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$$@@" is equivalent to "$$11" "$$22" ... When there are no positional parameters, "$$@@" and $$@@ expand to nothing (i.e., they are removed). ## Expands to the number of positional parameters in decimal. ?? Expands to the status of the most recently executed foreground pipeline. -- Expands to the current option flags as specified upon invoca- tion, by the sseett builtin command, or those set by the shell itself (such as the --ii option). $$ Expands to the process ID of the shell. In a () subshell, it expands to the process ID of the current shell, not the sub- shell. !! Expands to the process ID of the most recently executed back- ground (asynchronous) command. 00 Expands to the name of the shell or shell script. This is set at shell initialization. If bbaasshh is invoked with a file of com- mands, $$00 is set to the name of that file. If bbaasshh is started with the --cc option, then $$00 is set to the first argument after the string to be executed, if one is present. Otherwise, it is set to the file name used to invoke bbaasshh, as given by argument zero. __ At shell startup, set to the absolute file name of the shell or shell script being executed as passed in the argument list. Subsequently, expands to the last argument to the previous com- mand, after expansion. Also set to the full file name of each command executed and placed in the environment exported to that command. When checking mail, this parameter holds the name of the mail file currently being checked. SShheellll VVaarriiaabblleess The following variables are set by the shell: BBAASSHH Expands to the full file name used to invoke this instance of bbaasshh. BBAASSHH__AARRGGCC An array variable whose values are the number of parameters in each frame of the current bash execution call stack. The number of parameters to the current subroutine (shell function or script executed with .. or ssoouurrccee) is at the top of the stack. When a subroutine is executed, the number of parameters passed is pushed onto BBAASSHH__AARRGGCC. BBAASSHH__AARRGGVV An array variable containing all of the parameters in the cur- rent bash execution call stack. The final parameter of the last subroutine call is at the top of the stack; the first parameter of the initial call is at the bottom. When a subroutine is exe- cuted, the parameters supplied are pushed onto BBAASSHH__AARRGGVV. BBAASSHH__CCOOMMMMAANNDD The command currently being executed or about to be executed, unless the shell is executing a command as the result of a trap, in which case it is the command executing at the time of the trap. BBAASSHH__EEXXEECCUUTTIIOONN__SSTTRRIINNGG The command argument to the --cc invocation option. BBAASSHH__LLIINNEENNOO An array variable whose members are the line numbers in source files corresponding to each member of @var{FUNCNAME}. $${{BBAASSHH__LLIINNEENNOO[[_$_i]]}} is the line number in the source file where $${{FFUUNNCCNNAAMMEE[[_$_i _+ _1]]}} was called. The corresponding source file name is $${{BBAASSHH__SSOOUURRCCEE[[_$_i _+ _1]]}}.. UUssee LLIINNEENNOO ttoo oobbttaaiinn tthhee ccuurr-- rreenntt lliinnee nnuummbbeerr.. BBAASSHH__RREEMMAATTCCHH An array variable whose members are assigned by the ==~~ binary operator to the [[[[ conditional command. The element with index 0 is the portion of the string matching the entire regular expression. The element with index _n is the portion of the string matching the _nth parenthesized subexpression. This vari- able is read-only. BBAASSHH__SSOOUURRCCEE An array variable whose members are the source filenames corre- sponding to the elements in the FFUUNNCCNNAAMMEE array variable. BBAASSHH__SSUUBBSSHHEELLLL Incremented by one each time a subshell or subshell environment is spawned. The initial value is 0. BBAASSHH__VVEERRSSIINNFFOO A readonly array variable whose members hold version information for this instance of bbaasshh. The values assigned to the array members are as follows: BBAASSHH__VVEERRSSIINNFFOO[[0]] The major version number (the _r_e_l_e_a_s_e). BBAASSHH__VVEERRSSIINNFFOO[[1]] The minor version number (the _v_e_r_s_i_o_n). BBAASSHH__VVEERRSSIINNFFOO[[2]] The patch level. BBAASSHH__VVEERRSSIINNFFOO[[3]] The build version. BBAASSHH__VVEERRSSIINNFFOO[[4]] The release status (e.g., _b_e_t_a_1). BBAASSHH__VVEERRSSIINNFFOO[[5]] The value of MMAACCHHTTYYPPEE. BBAASSHH__VVEERRSSIIOONN Expands to a string describing the version of this instance of bbaasshh. CCOOMMPP__CCWWOORRDD An index into $${{CCOOMMPP__WWOORRDDSS}} of the word containing the current cursor position. This variable is available only in shell functions invoked by the programmable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). CCOOMMPP__LLIINNEE The current command line. This variable is available only in shell functions and external commands invoked by the pro- grammable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). CCOOMMPP__PPOOIINNTT The index of the current cursor position relative to the begin- ning of the current command. If the current cursor position is at the end of the current command, the value of this variable is equal to $${{##CCOOMMPP__LLIINNEE}}. This variable is available only in shell functions and external commands invoked by the pro- grammable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). CCOOMMPP__WWOORRDDBBRREEAAKKSS The set of characters that the Readline library treats as word separators when performing word completion. If CCOOMMPP__WWOORRDDBBRREEAAKKSS is unset, it loses its special properties, even if it is subse- quently reset. CCOOMMPP__WWOORRDDSS An array variable (see AArrrraayyss below) consisting of the individ- ual words in the current command line. This variable is avail- able only in shell functions invoked by the programmable comple- tion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). DDIIRRSSTTAACCKK An array variable (see AArrrraayyss below) containing the current con- tents of the directory stack. Directories appear in the stack in the order they are displayed by the ddiirrss builtin. Assigning to members of this array variable may be used to modify directo- ries already in the stack, but the ppuusshhdd and ppooppdd builtins must be used to add and remove directories. Assignment to this vari- able will not change the current directory. If DDIIRRSSTTAACCKK is unset, it loses its special properties, even if it is subse- quently reset. EEUUIIDD Expands to the effective user ID of the current user, initial- ized at shell startup. This variable is readonly. FFUUNNCCNNAAMMEE An array variable containing the names of all shell functions currently in the execution call stack. The element with index 0 is the name of any currently-executing shell function. The bot- tom-most element is "main". This variable exists only when a shell function is executing. Assignments to FFUUNNCCNNAAMMEE have no effect and return an error status. If FFUUNNCCNNAAMMEE is unset, it loses its special properties, even if it is subsequently reset. GGRROOUUPPSS An array variable containing the list of groups of which the current user is a member. Assignments to GGRROOUUPPSS have no effect and return an error status. If GGRROOUUPPSS is unset, it loses its special properties, even if it is subsequently reset. HHIISSTTCCMMDD The history number, or index in the history list, of the current command. If HHIISSTTCCMMDD is unset, it loses its special properties, even if it is subsequently reset. HHOOSSTTNNAAMMEE Automatically set to the name of the current host. HHOOSSTTTTYYPPEE Automatically set to a string that uniquely describes the type of machine on which bbaasshh is executing. The default is system- dependent. LLIINNEENNOO Each time this parameter is referenced, the shell substitutes a decimal number representing the current sequential line number (starting with 1) within a script or function. When not in a script or function, the value substituted is not guaranteed to be meaningful. If LLIINNEENNOO is unset, it loses its special proper- ties, even if it is subsequently reset. MMAACCHHTTYYPPEE Automatically set to a string that fully describes the system type on which bbaasshh is executing, in the standard GNU _c_p_u_-_c_o_m_- _p_a_n_y_-_s_y_s_t_e_m format. The default is system-dependent. OOLLDDPPWWDD The previous working directory as set by the ccdd command. OOPPTTAARRGG The value of the last option argument processed by the ggeettooppttss builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). OOPPTTIINNDD The index of the next argument to be processed by the ggeettooppttss builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). OOSSTTYYPPEE Automatically set to a string that describes the operating sys- tem on which bbaasshh is executing. The default is system-depen- dent. PPIIPPEESSTTAATTUUSS An array variable (see AArrrraayyss below) containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command). PPPPIIDD The process ID of the shell's parent. This variable is read- only. PPWWDD The current working directory as set by the ccdd command. RRAANNDDOOMM Each time this parameter is referenced, a random integer between 0 and 32767 is generated. The sequence of random numbers may be initialized by assigning a value to RRAANNDDOOMM. If RRAANNDDOOMM is unset, it loses its special properties, even if it is subsequently reset. RREEPPLLYY Set to the line of input read by the rreeaadd builtin command when no arguments are supplied. SSEECCOONNDDSS Each time this parameter is referenced, the number of seconds since shell invocation is returned. If a value is assigned to SSEECCOONNDDSS, the value returned upon subsequent references is the number of seconds since the assignment plus the value assigned. If SSEECCOONNDDSS is unset, it loses its special properties, even if it is subsequently reset. SSHHEELLLLOOPPTTSS A colon-separated list of enabled shell options. Each word in the list is a valid argument for the --oo option to the sseett builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The options appearing in SSHHEELLLLOOPPTTSS are those reported as _o_n by sseett --oo. If this variable is in the environment when bbaasshh starts up, each shell option in the list will be enabled before reading any startup files. This variable is read-only. SSHHLLVVLL Incremented by one each time an instance of bbaasshh is started. UUIIDD Expands to the user ID of the current user, initialized at shell startup. This variable is readonly. The following variables are used by the shell. In some cases, bbaasshh assigns a default value to a variable; these cases are noted below. BBAASSHH__EENNVV If this parameter is set when bbaasshh is executing a shell script, its value is interpreted as a filename containing commands to initialize the shell, as in _~_/_._b_a_s_h_r_c. The value of BBAASSHH__EENNVV is subjected to parameter expansion, command substitution, and arithmetic expansion before being interpreted as a file name. PPAATTHH is not used to search for the resultant file name. CCDDPPAATTHH The search path for the ccdd command. This is a colon-separated list of directories in which the shell looks for destination directories specified by the ccdd command. A sample value is ".:~:/usr". CCOOLLUUMMNNSS Used by the sseelleecctt builtin command to determine the terminal width when printing selection lists. Automatically set upon receipt of a SIGWINCH. CCOOMMPPRREEPPLLYY An array variable from which bbaasshh reads the possible completions generated by a shell function invoked by the programmable com- pletion facility (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). EEMMAACCSS If bbaasshh finds this variable in the environment when the shell starts with value "t", it assumes that the shell is running in an emacs shell buffer and disables line editing. FFCCEEDDIITT The default editor for the ffcc builtin command. FFIIGGNNOORREE A colon-separated list of suffixes to ignore when performing filename completion (see RREEAADDLLIINNEE below). A filename whose suf- fix matches one of the entries in FFIIGGNNOORREE is excluded from the list of matched filenames. A sample value is ".o:~". GGLLOOBBIIGGNNOORREE A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion. If a filename matched by a pathname expansion pattern also matches one of the patterns in GGLLOOBBIIGGNNOORREE, it is removed from the list of matches. HHIISSTTCCOONNTTRROOLL A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes _i_g_n_o_r_e_s_p_a_c_e, lines which begin with a ssppaaccee character are not saved in the history list. A value of _i_g_n_o_r_e_d_u_p_s causes lines matching the previous history entry to not be saved. A value of _i_g_n_o_r_e_b_o_t_h is shorthand for _i_g_n_o_r_e_s_p_a_c_e and _i_g_n_o_r_e_d_u_p_s. A value of _e_r_a_s_e_d_u_p_s causes all previous lines matching the current line to be removed from the history list before that line is saved. Any value not in the above list is ignored. If HHIISSTTCCOONNTTRROOLL is unset, or does not include a valid value, all lines read by the shell parser are saved on the history list, subject to the value of HHIISSTTIIGGNNOORREE. The second and subsequent lines of a multi-line compound command are not tested, and are added to the history regardless of the value of HHIISSTTCCOONNTTRROOLL. HHIISSTTFFIILLEE The name of the file in which command history is saved (see HHIISS-- TTOORRYY below). The default value is _~_/_._b_a_s_h___h_i_s_t_o_r_y. If unset, the command history is not saved when an interactive shell exits. HHIISSTTFFIILLEESSIIZZEE The maximum number of lines contained in the history file. When this variable is assigned a value, the history file is trun- cated, if necessary, to contain no more than that number of lines. The default value is 500. The history file is also truncated to this size after writing it when an interactive shell exits. HHIISSTTIIGGNNOORREE A colon-separated list of patterns used to decide which command lines should be saved on the history list. Each pattern is anchored at the beginning of the line and must match the com- plete line (no implicit `**' is appended). Each pattern is tested against the line after the checks specified by HHIISSTTCCOONN-- TTRROOLL are applied. In addition to the normal shell pattern matching characters, `&&' matches the previous history line. `&&' may be escaped using a backslash; the backslash is removed before attempting a match. The second and subsequent lines of a multi-line compound command are not tested, and are added to the history regardless of the value of HHIISSTTIIGGNNOORREE. HHIISSTTSSIIZZEE The number of commands to remember in the command history (see HHIISSTTOORRYY below). The default value is 500. HHIISSTTTTIIMMEEFFOORRMMAATT If this variable is set and not null, its value is used as a format string for _s_t_r_f_t_i_m_e(3) to print the time stamp associated with each history entry displayed by the hhiissttoorryy builtin. If this variable is set, time stamps are written to the history file so they may be preserved across shell sessions. HHOOMMEE The home directory of the current user; the default argument for the ccdd builtin command. The value of this variable is also used when performing tilde expansion. HHOOSSTTFFIILLEE Contains the name of a file in the same format as _/_e_t_c_/_h_o_s_t_s that should be read when the shell needs to complete a hostname. The list of possible hostname completions may be changed while the shell is running; the next time hostname completion is attempted after the value is changed, bbaasshh adds the contents of the new file to the existing list. If HHOOSSTTFFIILLEE is set, but has no value, bbaasshh attempts to read _/_e_t_c_/_h_o_s_t_s to obtain the list of possible hostname completions. When HHOOSSTTFFIILLEE is unset, the hostname list is cleared. IIFFSS The _I_n_t_e_r_n_a_l _F_i_e_l_d _S_e_p_a_r_a_t_o_r that is used for word splitting after expansion and to split lines into words with the rreeaadd builtin command. The default value is ``''. IIGGNNOORREEEEOOFF Controls the action of an interactive shell on receipt of an EEOOFF character as the sole input. If set, the value is the number of consecutive EEOOFF characters which must be typed as the first characters on an input line before bbaasshh exits. If the variable exists but does not have a numeric value, or has no value, the default value is 10. If it does not exist, EEOOFF signifies the end of input to the shell. IINNPPUUTTRRCC The filename for the rreeaaddlliinnee startup file, overriding the default of _~_/_._i_n_p_u_t_r_c (see RREEAADDLLIINNEE below). LLAANNGG Used to determine the locale category for any category not specifically selected with a variable starting with LLCC__. LLCC__AALLLL This variable overrides the value of LLAANNGG and any other LLCC__ variable specifying a locale category. LLCC__CCOOLLLLAATTEE This variable determines the collation order used when sorting the results of pathname expansion, and determines the behavior of range expressions, equivalence classes, and collating sequences within pathname expansion and pattern matching. LLCC__CCTTYYPPEE This variable determines the interpretation of characters and the behavior of character classes within pathname expansion and pattern matching. LLCC__MMEESSSSAAGGEESS This variable determines the locale used to translate double- quoted strings preceded by a $$. LLCC__NNUUMMEERRIICC This variable determines the locale category used for number formatting. LLIINNEESS Used by the sseelleecctt builtin command to determine the column length for printing selection lists. Automatically set upon receipt of a SIGWINCH. MMAAIILL If this parameter is set to a file name and the MMAAIILLPPAATTHH vari- able is not set, bbaasshh informs the user of the arrival of mail in the specified file. MMAAIILLCCHHEECCKK Specifies how often (in seconds) bbaasshh checks for mail. The default is 60 seconds. When it is time to check for mail, the shell does so before displaying the primary prompt. If this variable is unset, or set to a value that is not a number greater than or equal to zero, the shell disables mail checking. MMAAIILLPPAATTHH A colon-separated list of file names to be checked for mail. The message to be printed when mail arrives in a particular file may be specified by separating the file name from the message with a `?'. When used in the text of the message, $$__ expands to the name of the current mailfile. Example: MMAAIILLPPAATTHH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"' BBaasshh supplies a default value for this variable, but the loca- tion of the user mail files that it uses is system dependent (e.g., /var/mail/$$UUSSEERR). OOPPTTEERRRR If set to the value 1, bbaasshh displays error messages generated by the ggeettooppttss builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). OOPPTTEERRRR is initialized to 1 each time the shell is invoked or a shell script is executed. PPAATTHH The search path for commands. It is a colon-separated list of directories in which the shell looks for commands (see CCOOMMMMAANNDD EEXXEECCUUTTIIOONN below). A zero-length (null) directory name in the value of PPAATTHH indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon. The default path is system-dependent, and is set by the administrator who installs bbaasshh. A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''. PPOOSSIIXXLLYY__CCOORRRREECCTT If this variable is in the environment when bbaasshh starts, the shell enters _p_o_s_i_x _m_o_d_e before reading the startup files, as if the ----ppoossiixx invocation option had been supplied. If it is set while the shell is running, bbaasshh enables _p_o_s_i_x _m_o_d_e, as if the command _s_e_t _-_o _p_o_s_i_x had been executed. PPRROOMMPPTT__CCOOMMMMAANNDD If set, the value is executed as a command prior to issuing each primary prompt. PPSS11 The value of this parameter is expanded (see PPRROOMMPPTTIINNGG below) and used as the primary prompt string. The default value is ``\\ss--\\vv\\$$ ''. PPSS22 The value of this parameter is expanded as with PPSS11 and used as the secondary prompt string. The default is ``>> ''. PPSS33 The value of this parameter is used as the prompt for the sseelleecctt command (see SSHHEELLLL GGRRAAMMMMAARR above). PPSS44 The value of this parameter is expanded as with PPSS11 and the value is printed before each command bbaasshh displays during an execution trace. The first character of PPSS44 is replicated mul- tiple times, as necessary, to indicate multiple levels of indi- rection. The default is ``++ ''. SSHHEELLLL The full pathname to the shell is kept in this environment vari- able. If it is not set when the shell starts, bbaasshh assigns to it the full pathname of the current user's login shell. TTIIMMEEFFOORRMMAATT The value of this parameter is used as a format string specify- ing how the timing information for pipelines prefixed with the ttiimmee reserved word should be displayed. The %% character intro- duces an escape sequence that is expanded to a time value or other information. The escape sequences and their meanings are as follows; the braces denote optional portions. %%%% A literal %%. %%[[_p]][[ll]]RR The elapsed time in seconds. %%[[_p]][[ll]]UU The number of CPU seconds spent in user mode. %%[[_p]][[ll]]SS The number of CPU seconds spent in system mode. %%PP The CPU percentage, computed as (%U + %S) / %R. The optional _p is a digit specifying the _p_r_e_c_i_s_i_o_n, the number of fractional digits after a decimal point. A value of 0 causes no decimal point or fraction to be output. At most three places after the decimal point may be specified; values of _p greater than 3 are changed to 3. If _p is not specified, the value 3 is used. The optional ll specifies a longer format, including minutes, of the form _M_Mm_S_S._F_Fs. The value of _p determines whether or not the fraction is included. If this variable is not set, bbaasshh acts as if it had the value $$''\\nnrreeaall\\tt%%33llRR\\nnuusseerr\\tt%%33llUU\\nnssyyss%%33llSS''. If the value is null, no timing information is displayed. A trailing newline is added when the format string is displayed. TTMMOOUUTT If set to a value greater than zero, TTMMOOUUTT is treated as the default timeout for the rreeaadd builtin. The sseelleecctt command termi- nates if input does not arrive after TTMMOOUUTT seconds when input is coming from a terminal. In an interactive shell, the value is interpreted as the number of seconds to wait for input after issuing the primary prompt. BBaasshh terminates after waiting for that number of seconds if input does not arrive. aauuttoo__rreessuummee This variable controls how the shell interacts with the user and job control. If this variable is set, single word simple com- mands without redirections are treated as candidates for resump- tion of an existing stopped job. There is no ambiguity allowed; if there is more than one job beginning with the string typed, the job most recently accessed is selected. The _n_a_m_e of a stopped job, in this context, is the command line used to start it. If set to the value _e_x_a_c_t, the string supplied must match the name of a stopped job exactly; if set to _s_u_b_s_t_r_i_n_g, the string supplied needs to match a substring of the name of a stopped job. The _s_u_b_s_t_r_i_n_g value provides functionality analo- gous to the %%?? job identifier (see JJOOBB CCOONNTTRROOLL below). If set to any other value, the supplied string must be a prefix of a stopped job's name; this provides functionality analogous to the %% job identifier. hhiissttcchhaarrss The two or three characters which control history expansion and tokenization (see HHIISSTTOORRYY EEXXPPAANNSSIIOONN below). The first character is the _h_i_s_t_o_r_y _e_x_p_a_n_s_i_o_n character, the character which signals the start of a history expansion, normally `!!'. The second character is the _q_u_i_c_k _s_u_b_s_t_i_t_u_t_i_o_n character, which is used as shorthand for re-running the previous command entered, substi- tuting one string for another in the command. The default is `^^'. The optional third character is the character which indi- cates that the remainder of the line is a comment when found as the first character of a word, normally `##'. The history com- ment character causes history substitution to be skipped for the remaining words on the line. It does not necessarily cause the shell parser to treat the rest of the line as a comment. AArrrraayyss BBaasshh provides one-dimensional array variables. Any variable may be used as an array; the ddeeccllaarree builtin will explicitly declare an array. There is no maximum limit on the size of an array, nor any requirement that members be indexed or assigned contiguously. Arrays are indexed using integers and are zero-based. An array is created automatically if any variable is assigned to using the syntax _n_a_m_e[_s_u_b_s_c_r_i_p_t]=_v_a_l_u_e. The _s_u_b_s_c_r_i_p_t is treated as an arithmetic expression that must evaluate to a number greater than or equal to zero. To explicitly declare an array, use ddeeccllaarree --aa _n_a_m_e (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). ddeeccllaarree --aa _n_a_m_e[[_s_u_b_s_c_r_i_p_t]] is also accepted; the _s_u_b_s_c_r_i_p_t is ignored. Attributes may be specified for an array variable using the ddeeccllaarree and rreeaaddoonnllyy builtins. Each attribute applies to all members of an array. Arrays are assigned to using compound assignments of the form _n_a_m_e=((value_1 ... value_n)), where each _v_a_l_u_e is of the form [_s_u_b_- _s_c_r_i_p_t]=_s_t_r_i_n_g. Only _s_t_r_i_n_g is required. If the optional brackets and subscript are supplied, that index is assigned to; otherwise the index of the element assigned is the last index assigned to by the statement plus one. Indexing starts at zero. This syntax is also accepted by the ddeeccllaarree builtin. Individual array elements may be assigned to using the _n_a_m_e[_s_u_b_s_c_r_i_p_t]=_v_a_l_u_e syntax introduced above. Any element of an array may be referenced using ${_n_a_m_e[_s_u_b_s_c_r_i_p_t]}. The braces are required to avoid conflicts with pathname expansion. If _s_u_b_s_c_r_i_p_t is @@ or **, the word expands to all members of _n_a_m_e. These subscripts differ only when the word appears within double quotes. If the word is double-quoted, ${_n_a_m_e[*]} expands to a single word with the value of each array member separated by the first character of the IIFFSS special variable, and ${_n_a_m_e[@]} expands each element of _n_a_m_e to a sep- arate word. When there are no array members, ${_n_a_m_e[@]} expands to nothing. This is analogous to the expansion of the special parameters ** and @@ (see SSppeecciiaall PPaarraammeetteerrss above). ${#_n_a_m_e[_s_u_b_s_c_r_i_p_t]} expands to the length of ${_n_a_m_e[_s_u_b_s_c_r_i_p_t]}. If _s_u_b_s_c_r_i_p_t is ** or @@, the expan- sion is the number of elements in the array. Referencing an array variable without a subscript is equivalent to referencing element zero. The uunnsseett builtin is used to destroy arrays. uunnsseett _n_a_m_e[_s_u_b_s_c_r_i_p_t] destroys the array element at index _s_u_b_s_c_r_i_p_t. uunnsseett _n_a_m_e, where _n_a_m_e is an array, or uunnsseett _n_a_m_e[_s_u_b_s_c_r_i_p_t], where _s_u_b_s_c_r_i_p_t is ** or @@, removes the entire array. The ddeeccllaarree, llooccaall, and rreeaaddoonnllyy builtins each accept a --aa option to specify an array. The rreeaadd builtin accepts a --aa option to assign a list of words read from the standard input to an array. The sseett and ddeeccllaarree builtins display array values in a way that allows them to be reused as assignments. EEXXPPAANNSSIIOONN Expansion is performed on the command line after it has been split into words. There are seven kinds of expansion performed: _b_r_a_c_e _e_x_p_a_n_s_i_o_n, _t_i_l_d_e _e_x_p_a_n_s_i_o_n, _p_a_r_a_m_e_t_e_r _a_n_d _v_a_r_i_a_b_l_e _e_x_p_a_n_s_i_o_n, _c_o_m_m_a_n_d _s_u_b_s_t_i_t_u_- _t_i_o_n, _a_r_i_t_h_m_e_t_i_c _e_x_p_a_n_s_i_o_n, _w_o_r_d _s_p_l_i_t_t_i_n_g, and _p_a_t_h_n_a_m_e _e_x_p_a_n_s_i_o_n. The order of expansions is: brace expansion, tilde expansion, parame- ter, variable and arithmetic expansion and command substitution (done in a left-to-right fashion), word splitting, and pathname expansion. On systems that can support it, there is an additional expansion avail- able: _p_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n. Only brace expansion, word splitting, and pathname expansion can change the number of words of the expansion; other expansions expand a single word to a single word. The only exceptions to this are the expansions of "$$@@" and "$${{_n_a_m_e[[@@]]}}" as explained above (see PPAARRAAMMEETTEERRSS). BBrraaccee EExxppaannssiioonn _B_r_a_c_e _e_x_p_a_n_s_i_o_n is a mechanism by which arbitrary strings may be gener- ated. This mechanism is similar to _p_a_t_h_n_a_m_e _e_x_p_a_n_s_i_o_n, but the file- names generated need not exist. Patterns to be brace expanded take the form of an optional _p_r_e_a_m_b_l_e, followed by either a series of comma-sep- arated strings or a sequence expression between a pair of braces, fol- lowed by an optional _p_o_s_t_s_c_r_i_p_t. The preamble is prefixed to each string contained within the braces, and the postscript is then appended to each resulting string, expanding left to right. Brace expansions may be nested. The results of each expanded string are not sorted; left to right order is preserved. For example, a{{d,c,b}}e expands into `ade ace abe'. A sequence expression takes the form {{_x...._y}}, where _x and _y are either integers or single characters. When integers are supplied, the expres- sion expands to each number between _x and _y, inclusive. When charac- ters are supplied, the expression expands to each character lexico- graphically between _x and _y, inclusive. Note that both _x and _y must be of the same type. Brace expansion is performed before any other expansions, and any char- acters special to other expansions are preserved in the result. It is strictly textual. BBaasshh does not apply any syntactic interpretation to the context of the expansion or the text between the braces. A correctly-formed brace expansion must contain unquoted opening and closing braces, and at least one unquoted comma or a valid sequence expression. Any incorrectly formed brace expansion is left unchanged. A {{ or ,, may be quoted with a backslash to prevent its being considered part of a brace expression. To avoid conflicts with parameter expan- sion, the string $${{ is not considered eligible for brace expansion. This construct is typically used as shorthand when the common prefix of the strings to be generated is longer than in the above example: mkdir /usr/local/src/bash/{old,new,dist,bugs} or chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} Brace expansion introduces a slight incompatibility with historical versions of sshh. sshh does not treat opening or closing braces specially when they appear as part of a word, and preserves them in the output. BBaasshh removes braces from words as a consequence of brace expansion. For example, a word entered to sshh as _f_i_l_e_{_1_,_2_} appears identically in the output. The same word is output as _f_i_l_e_1 _f_i_l_e_2 after expansion by bbaasshh. If strict compatibility with sshh is desired, start bbaasshh with the ++BB option or disable brace expansion with the ++BB option to the sseett com- mand (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). TTiillddee EExxppaannssiioonn If a word begins with an unquoted tilde character (`~~'), all of the characters preceding the first unquoted slash (or all characters, if there is no unquoted slash) are considered a _t_i_l_d_e_-_p_r_e_f_i_x. If none of the characters in the tilde-prefix are quoted, the characters in the tilde-prefix following the tilde are treated as a possible _l_o_g_i_n _n_a_m_e. If this login name is the null string, the tilde is replaced with the value of the shell parameter HHOOMMEE. If HHOOMMEE is unset, the home direc- tory of the user executing the shell is substituted instead. Other- wise, the tilde-prefix is replaced with the home directory associated with the specified login name. If the tilde-prefix is a `~+', the value of the shell variable PPWWDD replaces the tilde-prefix. If the tilde-prefix is a `~-', the value of the shell variable OOLLDDPPWWDD, if it is set, is substituted. If the char- acters following the tilde in the tilde-prefix consist of a number _N, optionally prefixed by a `+' or a `-', the tilde-prefix is replaced with the corresponding element from the directory stack, as it would be displayed by the ddiirrss builtin invoked with the tilde-prefix as an argu- ment. If the characters following the tilde in the tilde-prefix con- sist of a number without a leading `+' or `-', `+' is assumed. If the login name is invalid, or the tilde expansion fails, the word is unchanged. Each variable assignment is checked for unquoted tilde-prefixes immedi- ately following a :: or ==. In these cases, tilde expansion is also per- formed. Consequently, one may use file names with tildes in assign- ments to PPAATTHH, MMAAIILLPPAATTHH, and CCDDPPAATTHH, and the shell assigns the expanded value. PPaarraammeetteerr EExxppaannssiioonn The `$$' character introduces parameter expansion, command substitution, or arithmetic expansion. The parameter name or symbol to be expanded may be enclosed in braces, which are optional but serve to protect the variable to be expanded from characters immediately following it which could be interpreted as part of the name. When braces are used, the matching ending brace is the first `}}' not escaped by a backslash or within a quoted string, and not within an embedded arithmetic expansion, command substitution, or paramter expan- sion. ${_p_a_r_a_m_e_t_e_r} The value of _p_a_r_a_m_e_t_e_r is substituted. The braces are required when _p_a_r_a_m_e_t_e_r is a positional parameter with more than one digit, or when _p_a_r_a_m_e_t_e_r is followed by a character which is not to be interpreted as part of its name. If the first character of _p_a_r_a_m_e_t_e_r is an exclamation point, a level of variable indirection is introduced. BBaasshh uses the value of the vari- able formed from the rest of _p_a_r_a_m_e_t_e_r as the name of the variable; this variable is then expanded and that value is used in the rest of the substitution, rather than the value of _p_a_r_a_m_e_t_e_r itself. This is known as _i_n_d_i_r_e_c_t _e_x_p_a_n_s_i_o_n. The exceptions to this are the expansions of ${!_p_r_e_f_i_x*} and ${!!_n_a_m_e[_@]} described below. The exclamation point must immediately follow the left brace in order to introduce indirec- tion. In each of the cases below, _w_o_r_d is subject to tilde expansion, parame- ter expansion, command substitution, and arithmetic expansion. When not performing substring expansion, bbaasshh tests for a parameter that is unset or null; omitting the colon results in a test only for a parame- ter that is unset. ${_p_a_r_a_m_e_t_e_r::--_w_o_r_d} UUssee DDeeffaauulltt VVaalluueess. If _p_a_r_a_m_e_t_e_r is unset or null, the expan- sion of _w_o_r_d is substituted. Otherwise, the value of _p_a_r_a_m_e_t_e_r is substituted. ${_p_a_r_a_m_e_t_e_r::==_w_o_r_d} AAssssiiggnn DDeeffaauulltt VVaalluueess. If _p_a_r_a_m_e_t_e_r is unset or null, the expansion of _w_o_r_d is assigned to _p_a_r_a_m_e_t_e_r. The value of _p_a_r_a_m_- _e_t_e_r is then substituted. Positional parameters and special parameters may not be assigned to in this way. ${_p_a_r_a_m_e_t_e_r::??_w_o_r_d} DDiissppllaayy EErrrroorr iiff NNuullll oorr UUnnsseett. If _p_a_r_a_m_e_t_e_r is null or unset, the expansion of _w_o_r_d (or a message to that effect if _w_o_r_d is not present) is written to the standard error and the shell, if it is not interactive, exits. Otherwise, the value of _p_a_r_a_m_e_t_e_r is substituted. ${_p_a_r_a_m_e_t_e_r::++_w_o_r_d} UUssee AAlltteerrnnaattee VVaalluuee. If _p_a_r_a_m_e_t_e_r is null or unset, nothing is substituted, otherwise the expansion of _w_o_r_d is substituted. ${_p_a_r_a_m_e_t_e_r::_o_f_f_s_e_t} ${_p_a_r_a_m_e_t_e_r::_o_f_f_s_e_t::_l_e_n_g_t_h} SSuubbssttrriinngg EExxppaannssiioonn.. Expands to up to _l_e_n_g_t_h characters of _p_a_r_a_m_e_t_e_r starting at the character specified by _o_f_f_s_e_t. If _l_e_n_g_t_h is omitted, expands to the substring of _p_a_r_a_m_e_t_e_r start- ing at the character specified by _o_f_f_s_e_t. _l_e_n_g_t_h and _o_f_f_s_e_t are arithmetic expressions (see AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN below). _l_e_n_g_t_h must evaluate to a number greater than or equal to zero. If _o_f_f_s_e_t evaluates to a number less than zero, the value is used as an offset from the end of the value of _p_a_r_a_m_e_t_e_r. If _p_a_r_a_m_e_t_e_r is @@, the result is _l_e_n_g_t_h positional parameters beginning at _o_f_f_s_e_t. If _p_a_r_a_m_e_t_e_r is an array name indexed by @ or *, the result is the _l_e_n_g_t_h members of the array beginning with ${_p_a_r_a_m_e_t_e_r[_o_f_f_s_e_t]}. Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1. ${!!_p_r_e_f_i_x**} ${!!_p_r_e_f_i_x@@} Expands to the names of variables whose names begin with _p_r_e_f_i_x, separated by the first character of the IIFFSS special variable. ${!!_n_a_m_e[_@]} ${!!_n_a_m_e[_*]} If _n_a_m_e is an array variable, expands to the list of array indices (keys) assigned in _n_a_m_e. If _n_a_m_e is not an array, expands to 0 if _n_a_m_e is set and null otherwise. When _@ is used and the expansion appears within double quotes, each key expands to a separate word. ${##_p_a_r_a_m_e_t_e_r} The length in characters of the value of _p_a_r_a_m_e_t_e_r is substi- tuted. If _p_a_r_a_m_e_t_e_r is ** or @@, the value substituted is the number of positional parameters. If _p_a_r_a_m_e_t_e_r is an array name subscripted by ** or @@, the value substituted is the number of elements in the array. ${_p_a_r_a_m_e_t_e_r##_w_o_r_d} ${_p_a_r_a_m_e_t_e_r####_w_o_r_d} The _w_o_r_d is expanded to produce a pattern just as in pathname expansion. If the pattern matches the beginning of the value of _p_a_r_a_m_e_t_e_r, then the result of the expansion is the expanded value of _p_a_r_a_m_e_t_e_r with the shortest matching pattern (the ``##'' case) or the longest matching pattern (the ``####'' case) deleted. If _p_a_r_a_m_e_t_e_r is @@ or **, the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted with @@ or **, the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list. ${_p_a_r_a_m_e_t_e_r%%_w_o_r_d} ${_p_a_r_a_m_e_t_e_r%%%%_w_o_r_d} The _w_o_r_d is expanded to produce a pattern just as in pathname expansion. If the pattern matches a trailing portion of the expanded value of _p_a_r_a_m_e_t_e_r, then the result of the expansion is the expanded value of _p_a_r_a_m_e_t_e_r with the shortest matching pat- tern (the ``%%'' case) or the longest matching pattern (the ``%%%%'' case) deleted. If _p_a_r_a_m_e_t_e_r is @@ or **, the pattern removal operation is applied to each positional parameter in turn, and the expansion is the resultant list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted with @@ or **, the pattern removal operation is applied to each member of the array in turn, and the expansion is the resultant list. ${_p_a_r_a_m_e_t_e_r//_p_a_t_t_e_r_n//_s_t_r_i_n_g} ${_p_a_r_a_m_e_t_e_r////_p_a_t_t_e_r_n//_s_t_r_i_n_g} The _p_a_t_t_e_r_n is expanded to produce a pattern just as in pathname expansion. _P_a_r_a_m_e_t_e_r is expanded and the longest match of _p_a_t_- _t_e_r_n against its value is replaced with _s_t_r_i_n_g. In the first form, only the first match is replaced. The second form causes all matches of _p_a_t_t_e_r_n to be replaced with _s_t_r_i_n_g. If _p_a_t_t_e_r_n begins with ##, it must match at the beginning of the expanded value of _p_a_r_a_m_e_t_e_r. If _p_a_t_t_e_r_n begins with %%, it must match at the end of the expanded value of _p_a_r_a_m_e_t_e_r. If _s_t_r_i_n_g is null, matches of _p_a_t_t_e_r_n are deleted and the // following _p_a_t_t_e_r_n may be omitted. If _p_a_r_a_m_e_t_e_r is @@ or **, the substitution operation is applied to each positional parameter in turn, and the expan- sion is the resultant list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted with @@ or **, the substitution operation is applied to each member of the array in turn, and the expansion is the resultant list. CCoommmmaanndd SSuubbssttiittuuttiioonn _C_o_m_m_a_n_d _s_u_b_s_t_i_t_u_t_i_o_n allows the output of a command to replace the com- mand name. There are two forms: $$((_c_o_m_m_a_n_d)) or ``_c_o_m_m_a_n_d`` BBaasshh performs the expansion by executing _c_o_m_m_a_n_d and replacing the com- mand substitution with the standard output of the command, with any trailing newlines deleted. Embedded newlines are not deleted, but they may be removed during word splitting. The command substitution $$((ccaatt _f_i_l_e)) can be replaced by the equivalent but faster $$((<< _f_i_l_e)). When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by $$, ``, or \\. The first backquote not preceded by a backslash terminates the command sub- stitution. When using the $(_c_o_m_m_a_n_d) form, all characters between the parentheses make up the command; none are treated specially. Command substitutions may be nested. To nest when using the backquoted form, escape the inner backquotes with backslashes. If the substitution appears within double quotes, word splitting and pathname expansion are not performed on the results. AArriitthhmmeettiicc EExxppaannssiioonn Arithmetic expansion allows the evaluation of an arithmetic expression and the substitution of the result. The format for arithmetic expan- sion is: $$((((_e_x_p_r_e_s_s_i_o_n)))) The _e_x_p_r_e_s_s_i_o_n is treated as if it were within double quotes, but a double quote inside the parentheses is not treated specially. All tokens in the expression undergo parameter expansion, string expansion, command substitution, and quote removal. Arithmetic expansions may be nested. The evaluation is performed according to the rules listed below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. If _e_x_p_r_e_s_s_i_o_n is invalid, bbaasshh prints a message indicating failure and no substitution occurs. PPrroocceessss SSuubbssttiittuuttiioonn _P_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n is supported on systems that support named pipes (_F_I_F_O_s) or the //ddeevv//ffdd method of naming open files. It takes the form of <<((_l_i_s_t)) or >>((_l_i_s_t)). The process _l_i_s_t is run with its input or out- put connected to a _F_I_F_O or some file in //ddeevv//ffdd. The name of this file is passed as an argument to the current command as the result of the expansion. If the >>((_l_i_s_t)) form is used, writing to the file will pro- vide input for _l_i_s_t. If the <<((_l_i_s_t)) form is used, the file passed as an argument should be read to obtain the output of _l_i_s_t. When available, process substitution is performed simultaneously with parameter and variable expansion, command substitution, and arithmetic expansion. WWoorrdd SSpplliittttiinngg The shell scans the results of parameter expansion, command substitu- tion, and arithmetic expansion that did not occur within double quotes for _w_o_r_d _s_p_l_i_t_t_i_n_g. The shell treats each character of IIFFSS as a delimiter, and splits the results of the other expansions into words on these characters. If IIFFSS is unset, or its value is exactly <><><>, the default, then any sequence of IIFFSS characters serves to delimit words. If IIFFSS has a value other than the default, then sequences of the whitespace characters ssppaaccee and ttaabb are ignored at the beginning and end of the word, as long as the whitespace character is in the value of IIFFSS (an IIFFSS whitespace character). Any character in IIFFSS that is not IIFFSS whitespace, along with any adjacent IIFFSS whitespace characters, delimits a field. A sequence of IIFFSS whitespace characters is also treated as a delimiter. If the value of IIFFSS is null, no word splitting occurs. Explicit null arguments ("""" or '''') are retained. Unquoted implicit null arguments, resulting from the expansion of parameters that have no values, are removed. If a parameter with no value is expanded within double quotes, a null argument results and is retained. Note that if no expansion occurs, no splitting is performed. PPaatthhnnaammee EExxppaannssiioonn After word splitting, unless the --ff option has been set, bbaasshh scans each word for the characters **, ??, and [[. If one of these characters appears, then the word is regarded as a _p_a_t_t_e_r_n, and replaced with an alphabetically sorted list of file names matching the pattern. If no matching file names are found, and the shell option nnuullllgglloobb is dis- abled, the word is left unchanged. If the nnuullllgglloobb option is set, and no matches are found, the word is removed. If the ffaaiillgglloobb shell option is set, and no matches are found, an error message is printed and the command is not executed. If the shell option nnooccaasseegglloobb is enabled, the match is performed without regard to the case of alpha- betic characters. When a pattern is used for pathname expansion, the character ````..'''' at the start of a name or immediately following a slash must be matched explicitly, unless the shell option ddoottgglloobb is set. When matching a pathname, the slash character must always be matched explicitly. In other cases, the ````..'''' character is not treated specially. See the description of sshhoopptt below under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS for a description of the nnooccaasseegglloobb, nnuullllgglloobb, ffaaiill-- gglloobb, and ddoottgglloobb shell options. The GGLLOOBBIIGGNNOORREE shell variable may be used to restrict the set of file names matching a _p_a_t_t_e_r_n. If GGLLOOBBIIGGNNOORREE is set, each matching file name that also matches one of the patterns in GGLLOOBBIIGGNNOORREE is removed from the list of matches. The file names ````..'''' and ````....'''' are always ignored when GGLLOOBBIIGGNNOORREE is set and not null. However, setting GGLLOOBBIIGG-- NNOORREE to a non-null value has the effect of enabling the ddoottgglloobb shell option, so all other file names beginning with a ````..'''' will match. To get the old behavior of ignoring file names beginning with a ````..'''', make ````..**'''' one of the patterns in GGLLOOBBIIGGNNOORREE. The ddoottgglloobb option is disabled when GGLLOOBBIIGGNNOORREE is unset. PPaatttteerrnn MMaattcchhiinngg Any character that appears in a pattern, other than the special pattern characters described below, matches itself. The NUL character may not occur in a pattern. A backslash escapes the following character; the escaping backslash is discarded when matching. The special pattern characters must be quoted if they are to be matched literally. The special pattern characters have the following meanings: ** Matches any string, including the null string. ?? Matches any single character. [[......]] Matches any one of the enclosed characters. A pair of charac- ters separated by a hyphen denotes a _r_a_n_g_e _e_x_p_r_e_s_s_i_o_n; any char- acter that sorts between those two characters, inclusive, using the current locale's collating sequence and character set, is matched. If the first character following the [[ is a !! or a ^^ then any character not enclosed is matched. The sorting order of characters in range expressions is determined by the current locale and the value of the LLCC__CCOOLLLLAATTEE shell variable, if set. A -- may be matched by including it as the first or last charac- ter in the set. A ]] may be matched by including it as the first character in the set. Within [[ and ]], _c_h_a_r_a_c_t_e_r _c_l_a_s_s_e_s can be specified using the syntax [[::_c_l_a_s_s::]], where _c_l_a_s_s is one of the following classes defined in the POSIX.2 standard: aallnnuumm aallpphhaa aasscciiii bbllaannkk ccnnttrrll ddiiggiitt ggrraapphh lloowweerr pprriinntt ppuunncctt ssppaaccee uuppppeerr wwoorrdd xxddiiggiitt A character class matches any character belonging to that class. The wwoorrdd character class matches letters, digits, and the char- acter _. Within [[ and ]], an _e_q_u_i_v_a_l_e_n_c_e _c_l_a_s_s can be specified using the syntax [[==_c==]], which matches all characters with the same colla- tion weight (as defined by the current locale) as the character _c. Within [[ and ]], the syntax [[.._s_y_m_b_o_l..]] matches the collating sym- bol _s_y_m_b_o_l. If the eexxttgglloobb shell option is enabled using the sshhoopptt builtin, several extended pattern matching operators are recognized. In the following description, a _p_a_t_t_e_r_n_-_l_i_s_t is a list of one or more patterns separated by a ||. Composite patterns may be formed using one or more of the fol- lowing sub-patterns: ??((_p_a_t_t_e_r_n_-_l_i_s_t)) Matches zero or one occurrence of the given patterns **((_p_a_t_t_e_r_n_-_l_i_s_t)) Matches zero or more occurrences of the given patterns ++((_p_a_t_t_e_r_n_-_l_i_s_t)) Matches one or more occurrences of the given patterns @@((_p_a_t_t_e_r_n_-_l_i_s_t)) Matches exactly one of the given patterns !!((_p_a_t_t_e_r_n_-_l_i_s_t)) Matches anything except one of the given patterns QQuuoottee RReemmoovvaall After the preceding expansions, all unquoted occurrences of the charac- ters \\, '', and "" that did not result from one of the above expansions are removed. RREEDDIIRREECCTTIIOONN Before a command is executed, its input and output may be _r_e_d_i_r_e_c_t_e_d using a special notation interpreted by the shell. Redirection may also be used to open and close files for the current shell execution environment. The following redirection operators may precede or appear anywhere within a _s_i_m_p_l_e _c_o_m_m_a_n_d or may follow a _c_o_m_m_a_n_d. Redirections are processed in the order they appear, from left to right. In the following descriptions, if the file descriptor number is omit- ted, and the first character of the redirection operator is <<, the redirection refers to the standard input (file descriptor 0). If the first character of the redirection operator is >>, the redirection refers to the standard output (file descriptor 1). The word following the redirection operator in the following descrip- tions, unless otherwise noted, is subjected to brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expan- sion, quote removal, pathname expansion, and word splitting. If it expands to more than one word, bbaasshh reports an error. Note that the order of redirections is significant. For example, the command ls >> dirlist 2>>&&1 directs both standard output and standard error to the file _d_i_r_l_i_s_t, while the command ls 2>>&&1 >> dirlist directs only the standard output to file _d_i_r_l_i_s_t, because the standard error was duplicated as standard output before the standard output was redirected to _d_i_r_l_i_s_t. BBaasshh handles several filenames specially when they are used in redirec- tions, as described in the following table: //ddeevv//ffdd//_f_d If _f_d is a valid integer, file descriptor _f_d is dupli- cated. //ddeevv//ssttddiinn File descriptor 0 is duplicated. //ddeevv//ssttddoouutt File descriptor 1 is duplicated. //ddeevv//ssttddeerrrr File descriptor 2 is duplicated. //ddeevv//ttccpp//_h_o_s_t//_p_o_r_t If _h_o_s_t is a valid hostname or Internet address, and _p_o_r_t is an integer port number or service name, bbaasshh attempts to open a TCP connection to the corresponding socket. //ddeevv//uuddpp//_h_o_s_t//_p_o_r_t If _h_o_s_t is a valid hostname or Internet address, and _p_o_r_t is an integer port number or service name, bbaasshh attempts to open a UDP connection to the corresponding socket. A failure to open or create a file causes the redirection to fail. RReeddiirreeccttiinngg IInnppuutt Redirection of input causes the file whose name results from the expan- sion of _w_o_r_d to be opened for reading on file descriptor _n, or the standard input (file descriptor 0) if _n is not specified. The general format for redirecting input is: [_n]<<_w_o_r_d RReeddiirreeccttiinngg OOuuttppuutt Redirection of output causes the file whose name results from the expansion of _w_o_r_d to be opened for writing on file descriptor _n, or the standard output (file descriptor 1) if _n is not specified. If the file does not exist it is created; if it does exist it is truncated to zero size. The general format for redirecting output is: [_n]>>_w_o_r_d If the redirection operator is >>, and the nnoocclloobbbbeerr option to the sseett builtin has been enabled, the redirection will fail if the file whose name results from the expansion of _w_o_r_d exists and is a regular file. If the redirection operator is >>||, or the redirection operator is >> and the nnoocclloobbbbeerr option to the sseett builtin command is not enabled, the redirection is attempted even if the file named by _w_o_r_d exists. AAppppeennddiinngg RReeddiirreecctteedd OOuuttppuutt Redirection of output in this fashion causes the file whose name results from the expansion of _w_o_r_d to be opened for appending on file descriptor _n, or the standard output (file descriptor 1) if _n is not specified. If the file does not exist it is created. The general format for appending output is: [_n]>>>>_w_o_r_d RReeddiirreeccttiinngg SSttaannddaarrdd OOuuttppuutt aanndd SSttaannddaarrdd EErrrroorr BBaasshh allows both the standard output (file descriptor 1) and the stan- dard error output (file descriptor 2) to be redirected to the file whose name is the expansion of _w_o_r_d with this construct. There are two formats for redirecting standard output and standard error: &&>>_w_o_r_d and >>&&_w_o_r_d Of the two forms, the first is preferred. This is semantically equiva- lent to >>_w_o_r_d 2>>&&1 HHeerree DDooccuummeennttss This type of redirection instructs the shell to read input from the current source until a line containing only _w_o_r_d (with no trailing blanks) is seen. All of the lines read up to that point are then used as the standard input for a command. The format of here-documents is: <<<<[--]_w_o_r_d _h_e_r_e_-_d_o_c_u_m_e_n_t _d_e_l_i_m_i_t_e_r No parameter expansion, command substitution, arithmetic expansion, or pathname expansion is performed on _w_o_r_d. If any characters in _w_o_r_d are quoted, the _d_e_l_i_m_i_t_e_r is the result of quote removal on _w_o_r_d, and the lines in the here-document are not expanded. If _w_o_r_d is unquoted, all lines of the here-document are subjected to parameter expansion, com- mand substitution, and arithmetic expansion. In the latter case, the character sequence \\<> is ignored, and \\ must be used to quote the characters \\, $$, and ``. If the redirection operator is <<<<--, then all leading tab characters are stripped from input lines and the line containing _d_e_l_i_m_i_t_e_r. This allows here-documents within shell scripts to be indented in a natural fashion. HHeerree SSttrriinnggss A variant of here documents, the format is: <<<<<<_w_o_r_d The _w_o_r_d is expanded and supplied to the command on its standard input. DDuupplliiccaattiinngg FFiillee DDeessccrriippttoorrss The redirection operator [_n]<<&&_w_o_r_d is used to duplicate input file descriptors. If _w_o_r_d expands to one or more digits, the file descriptor denoted by _n is made to be a copy of that file descriptor. If the digits in _w_o_r_d do not specify a file descriptor open for input, a redirection error occurs. If _w_o_r_d evalu- ates to --, file descriptor _n is closed. If _n is not specified, the standard input (file descriptor 0) is used. The operator [_n]>>&&_w_o_r_d is used similarly to duplicate output file descriptors. If _n is not specified, the standard output (file descriptor 1) is used. If the digits in _w_o_r_d do not specify a file descriptor open for output, a redirection error occurs. As a special case, if _n is omitted, and _w_o_r_d does not expand to one or more digits, the standard output and standard error are redirected as described previously. MMoovviinngg FFiillee DDeessccrriippttoorrss The redirection operator [_n]<<&&_d_i_g_i_t-- moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard input (file descriptor 0) if _n is not specified. _d_i_g_i_t is closed after being duplicated to _n. Similarly, the redirection operator [_n]>>&&_d_i_g_i_t-- moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard output (file descriptor 1) if _n is not specified. OOppeenniinngg FFiillee DDeessccrriippttoorrss ffoorr RReeaaddiinngg aanndd WWrriittiinngg The redirection operator [_n]<<>>_w_o_r_d causes the file whose name is the expansion of _w_o_r_d to be opened for both reading and writing on file descriptor _n, or on file descriptor 0 if _n is not specified. If the file does not exist, it is created. AALLIIAASSEESS _A_l_i_a_s_e_s allow a string to be substituted for a word when it is used as the first word of a simple command. The shell maintains a list of aliases that may be set and unset with the aalliiaass and uunnaalliiaass builtin commands (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The first word of each simple command, if unquoted, is checked to see if it has an alias. If so, that word is replaced by the text of the alias. The characters //, $$, ``, and == and any of the shell _m_e_t_a_c_h_a_r_a_c_t_e_r_s or quoting characters listed above may not appear in an alias name. The replacement text may contain any valid shell input, including shell metacharacters. The first word of the replacement text is tested for aliases, but a word that is identical to an alias being expanded is not expanded a second time. This means that one may alias llss to llss --FF, for instance, and bbaasshh does not try to recursively expand the replacement text. If the last character of the alias value is a _b_l_a_n_k, then the next command word following the alias is also checked for alias expansion. Aliases are created and listed with the aalliiaass command, and removed with the uunnaalliiaass command. There is no mechanism for using arguments in the replacement text. If arguments are needed, a shell function should be used (see FFUUNNCCTTIIOONNSS below). Aliases are not expanded when the shell is not interactive, unless the eexxppaanndd__aalliiaasseess shell option is set using sshhoopptt (see the description of sshhoopptt under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The rules concerning the definition and use of aliases are somewhat confusing. BBaasshh always reads at least one complete line of input before executing any of the commands on that line. Aliases are expanded when a command is read, not when it is executed. Therefore, an alias definition appearing on the same line as another command does not take effect until the next line of input is read. The commands following the alias definition on that line are not affected by the new alias. This behavior is also an issue when functions are executed. Aliases are expanded when a function definition is read, not when the function is executed, because a function definition is itself a com- pound command. As a consequence, aliases defined in a function are not available until after that function is executed. To be safe, always put alias definitions on a separate line, and do not use aalliiaass in com- pound commands. For almost every purpose, aliases are superseded by shell functions. FFUUNNCCTTIIOONNSS A shell function, defined as described above under SSHHEELLLL GGRRAAMMMMAARR, stores a series of commands for later execution. When the name of a shell function is used as a simple command name, the list of commands associated with that function name is executed. Functions are executed in the context of the current shell; no new process is created to interpret them (contrast this with the execution of a shell script). When a function is executed, the arguments to the function become the positional parameters during its execution. The special parameter ## is updated to reflect the change. Special parameter 0 is unchanged. The first element of the FFUUNNCCNNAAMMEE variable is set to the name of the func- tion while the function is executing. All other aspects of the shell execution environment are identical between a function and its caller with the exception that the DDEEBBUUGG trap (see the description of the ttrraapp builtin under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) is not inherited unless the function has been given the ttrraaccee attribute (see the description of the ddeeccllaarree builtin below) or the --oo ffuunnccttrraaccee shell option has been enabled with the sseett builtin (in which case all functions inherit the DDEEBBUUGG trap). Variables local to the function may be declared with the llooccaall builtin command. Ordinarily, variables and their values are shared between the function and its caller. If the builtin command rreettuurrnn is executed in a function, the function completes and execution resumes with the next command after the func- tion call. Any command associated with the RREETTUURRNN trap is executed before execution resumes. When a function completes, the values of the positional parameters and the special parameter ## are restored to the values they had prior to the function's execution. Function names and definitions may be listed with the --ff option to the ddeeccllaarree or ttyyppeesseett builtin commands. The --FF option to ddeeccllaarree or ttyyppee-- sseett will list the function names only (and optionally the source file and line number, if the eexxttddeebbuugg shell option is enabled). Functions may be exported so that subshells automatically have them defined with the --ff option to the eexxppoorrtt builtin. Note that shell functions and variables with the same name may result in multiple identically-named entries in the environment passed to the shell's children. Care should be taken in cases where this may cause a problem. Functions may be recursive. No limit is imposed on the number of recursive calls. AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN The shell allows arithmetic expressions to be evaluated, under certain circumstances (see the lleett and ddeeccllaarree builtin commands and AArriitthhmmeettiicc EExxppaannssiioonn). Evaluation is done in fixed-width integers with no check for overflow, though division by 0 is trapped and flagged as an error. The operators and their precedence, associativity, and values are the same as in the C language. The following list of operators is grouped into levels of equal-precedence operators. The levels are listed in order of decreasing precedence. _i_d++++ _i_d---- variable post-increment and post-decrement ++++_i_d ----_i_d variable pre-increment and pre-decrement -- ++ unary minus and plus !! ~~ logical and bitwise negation **** exponentiation ** // %% multiplication, division, remainder ++ -- addition, subtraction <<<< >>>> left and right bitwise shifts <<== >>== << >> comparison ==== !!== equality and inequality && bitwise AND ^^ bitwise exclusive OR || bitwise OR &&&& logical AND |||| logical OR _e_x_p_r??_e_x_p_r::_e_x_p_r conditional operator == **== //== %%== ++== --== <<<<== >>>>== &&== ^^== ||== assignment _e_x_p_r_1 ,, _e_x_p_r_2 comma Shell variables are allowed as operands; parameter expansion is per- formed before the expression is evaluated. Within an expression, shell variables may also be referenced by name without using the parameter expansion syntax. A shell variable that is null or unset evaluates to 0 when referenced by name without using the parameter expansion syntax. The value of a variable is evaluated as an arithmetic expression when it is referenced, or when a variable which has been given the _i_n_t_e_g_e_r attribute using ddeeccllaarree --ii is assigned a value. A null value evaluates to 0. A shell variable need not have its integer attribute turned on to be used in an expression. Constants with a leading 0 are interpreted as octal numbers. A leading 0x or 0X denotes hexadecimal. Otherwise, numbers take the form [_b_a_s_e_#]n, where _b_a_s_e is a decimal number between 2 and 64 representing the arithmetic base, and _n is a number in that base. If _b_a_s_e_# is omit- ted, then base 10 is used. The digits greater than 9 are represented by the lowercase letters, the uppercase letters, @, and _, in that order. If _b_a_s_e is less than or equal to 36, lowercase and uppercase letters may be used interchangably to represent numbers between 10 and 35. Operators are evaluated in order of precedence. Sub-expressions in parentheses are evaluated first and may override the precedence rules above. CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS Conditional expressions are used by the [[[[ compound command and the tteesstt and [[ builtin commands to test file attributes and perform string and arithmetic comparisons. Expressions are formed from the following unary or binary primaries. If any _f_i_l_e argument to one of the pri- maries is of the form _/_d_e_v_/_f_d_/_n, then file descriptor _n is checked. If the _f_i_l_e argument to one of the primaries is one of _/_d_e_v_/_s_t_d_i_n, _/_d_e_v_/_s_t_d_o_u_t, or _/_d_e_v_/_s_t_d_e_r_r, file descriptor 0, 1, or 2, respectively, is checked. --aa _f_i_l_e True if _f_i_l_e exists. --bb _f_i_l_e True if _f_i_l_e exists and is a block special file. --cc _f_i_l_e True if _f_i_l_e exists and is a character special file. --dd _f_i_l_e True if _f_i_l_e exists and is a directory. --ee _f_i_l_e True if _f_i_l_e exists. --ff _f_i_l_e True if _f_i_l_e exists and is a regular file. --gg _f_i_l_e True if _f_i_l_e exists and is set-group-id. --hh _f_i_l_e True if _f_i_l_e exists and is a symbolic link. --kk _f_i_l_e True if _f_i_l_e exists and its ``sticky'' bit is set. --pp _f_i_l_e True if _f_i_l_e exists and is a named pipe (FIFO). --rr _f_i_l_e True if _f_i_l_e exists and is readable. --ss _f_i_l_e True if _f_i_l_e exists and has a size greater than zero. --tt _f_d True if file descriptor _f_d is open and refers to a terminal. --uu _f_i_l_e True if _f_i_l_e exists and its set-user-id bit is set. --ww _f_i_l_e True if _f_i_l_e exists and is writable. --xx _f_i_l_e True if _f_i_l_e exists and is executable. --OO _f_i_l_e True if _f_i_l_e exists and is owned by the effective user id. --GG _f_i_l_e True if _f_i_l_e exists and is owned by the effective group id. --LL _f_i_l_e True if _f_i_l_e exists and is a symbolic link. --SS _f_i_l_e True if _f_i_l_e exists and is a socket. --NN _f_i_l_e True if _f_i_l_e exists and has been modified since it was last read. _f_i_l_e_1 -nntt _f_i_l_e_2 True if _f_i_l_e_1 is newer (according to modification date) than _f_i_l_e_2, or if _f_i_l_e_1 exists and _f_i_l_e_2 does not. _f_i_l_e_1 -oott _f_i_l_e_2 True if _f_i_l_e_1 is older than _f_i_l_e_2, or if _f_i_l_e_2 exists and _f_i_l_e_1 does not. _f_i_l_e_1 --eeff _f_i_l_e_2 True if _f_i_l_e_1 and _f_i_l_e_2 refer to the same device and inode num- bers. --oo _o_p_t_n_a_m_e True if shell option _o_p_t_n_a_m_e is enabled. See the list of options under the description of the --oo option to the sseett builtin below. --zz _s_t_r_i_n_g True if the length of _s_t_r_i_n_g is zero. _s_t_r_i_n_g --nn _s_t_r_i_n_g True if the length of _s_t_r_i_n_g is non-zero. _s_t_r_i_n_g_1 ==== _s_t_r_i_n_g_2 True if the strings are equal. == may be used in place of ==== for strict POSIX compliance. _s_t_r_i_n_g_1 !!== _s_t_r_i_n_g_2 True if the strings are not equal. _s_t_r_i_n_g_1 << _s_t_r_i_n_g_2 True if _s_t_r_i_n_g_1 sorts before _s_t_r_i_n_g_2 lexicographically in the current locale. _s_t_r_i_n_g_1 >> _s_t_r_i_n_g_2 True if _s_t_r_i_n_g_1 sorts after _s_t_r_i_n_g_2 lexicographically in the current locale. _a_r_g_1 OOPP _a_r_g_2 OOPP is one of --eeqq, --nnee, --lltt, --llee, --ggtt, or --ggee. These arithmetic binary operators return true if _a_r_g_1 is equal to, not equal to, less than, less than or equal to, greater than, or greater than or equal to _a_r_g_2, respectively. _A_r_g_1 and _a_r_g_2 may be positive or negative integers. SSIIMMPPLLEE CCOOMMMMAANNDD EEXXPPAANNSSIIOONN When a simple command is executed, the shell performs the following expansions, assignments, and redirections, from left to right. 1. The words that the parser has marked as variable assignments (those preceding the command name) and redirections are saved for later processing. 2. The words that are not variable assignments or redirections are expanded. If any words remain after expansion, the first word is taken to be the name of the command and the remaining words are the arguments. 3. Redirections are performed as described above under RREEDDIIRREECCTTIIOONN. 4. The text after the == in each variable assignment undergoes tilde expansion, parameter expansion, command substitution, arithmetic expansion, and quote removal before being assigned to the vari- able. If no command name results, the variable assignments affect the current shell environment. Otherwise, the variables are added to the environ- ment of the executed command and do not affect the current shell envi- ronment. If any of the assignments attempts to assign a value to a readonly variable, an error occurs, and the command exits with a non- zero status. If no command name results, redirections are performed, but do not affect the current shell environment. A redirection error causes the command to exit with a non-zer