summaryrefslogtreecommitdiff
path: root/doc/bash.0
diff options
context:
space:
mode:
Diffstat (limited to 'doc/bash.0')
-rw-r--r--doc/bash.0782
1 files changed, 393 insertions, 389 deletions
diff --git a/doc/bash.0 b/doc/bash.0
index 63490df2..38b70e44 100644
--- a/doc/bash.0
+++ b/doc/bash.0
@@ -1225,59 +1225,60 @@ PPAARRAAMMEETTEERRSS
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).
+ BBaasshh can be configured to supply a default value for this vari-
+ able (there is no value by default), but the location 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
+ 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
+ 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
+ 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/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''.
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
+ 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.
PPRROOMMPPTT__DDIIRRTTRRIIMM
- If set to a number greater than zero, the value is used as the
+ If set to a number greater than zero, the value is used as the
number of trailing directory components to retain when expanding
- the \\ww and \\WW prompt string escapes (see PPRROOMMPPTTIINNGG below).
+ the \\ww and \\WW prompt string escapes (see PPRROOMMPPTTIINNGG below).
Characters removed are replaced with an ellipsis.
- PPSS00 The value of this parameter is expanded (see PPRROOMMPPTTIINNGG below)
- and displayed by interactive shells after reading a command and
+ PPSS00 The value of this parameter is expanded (see PPRROOMMPPTTIINNGG below)
+ and displayed by interactive shells after reading a command and
before the command is executed.
- PPSS11 The value of this parameter is expanded (see PPRROOMMPPTTIINNGG below)
- and used as the primary prompt string. The default value is
+ 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
+ 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-
+ 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
+ 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
+ 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.
@@ -1285,77 +1286,77 @@ PPAARRAAMMEETTEERRSS
%%[[_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
+ 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
+ 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 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\\tt%%33llSS''. If the value is null,
+ If this variable is not set, bbaasshh acts as if it had the value
+ $$''\\nnrreeaall\\tt%%33llRR\\nnuusseerr\\tt%%33llUU\\nnssyyss\\tt%%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
+ 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
+ coming from a terminal. In an interactive shell, the value is
interpreted as the number of seconds to wait for a line of input
after issuing the primary prompt. BBaasshh terminates after waiting
- for that number of seconds if a complete line of input does not
+ for that number of seconds if a complete line of input does not
arrive.
- TTMMPPDDIIRR If set, bbaasshh uses its value as the name of a directory in which
+ TTMMPPDDIIRR If set, bbaasshh uses its value as the name of a directory in which
bbaasshh creates temporary files for the shell's use.
aauuttoo__rreessuummee
This variable controls how the shell interacts with the user and
- job control. If this variable is set, single word simple com-
+ 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
+ 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
%%_s_t_r_i_n_g job identifier.
hhiissttcchhaarrss
- The two or three characters which control history expansion and
+ 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-
+ 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
+ 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 indexed and associative array variables.
- Any variable may be used as an indexed 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 con-
- tiguously. Indexed arrays are referenced using integers (including
+ BBaasshh provides one-dimensional indexed and associative array variables.
+ Any variable may be used as an indexed 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 con-
+ tiguously. Indexed arrays are referenced using integers (including
arithmetic expressions) and are zero-based; associative arrays are ref-
erenced using arbitrary strings. Unless otherwise noted, indexed array
indices must be non-negative integers.
- An indexed array is created automatically if any variable is assigned
+ An indexed 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. To explicitly
- declare an indexed array, use ddeeccllaarree --aa _n_a_m_e (see SSHHEELLLL BBUUIILLTTIINN CCOOMM--
- MMAANNDDSS below). ddeeccllaarree --aa _n_a_m_e[[_s_u_b_s_c_r_i_p_t]] is also accepted; the _s_u_b_-
+ declare an indexed array, use ddeeccllaarree --aa _n_a_m_e (see SSHHEELLLL BBUUIILLTTIINN CCOOMM--
+ MMAANNDDSS 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.
Associative arrays are created using ddeeccllaarree --AA _n_a_m_e.
@@ -1363,130 +1364,130 @@ PPAARRAAMMEETTEERRSS
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. Indexed array assignments do not require anything but
+ 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. Indexed array assignments do not require anything but
_s_t_r_i_n_g. When assigning to indexed arrays, 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
+ 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.
When assigning to an associative array, the subscript is required.
- 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. When assigning to an indexed array, if _n_a_m_e is sub-
- scripted by a negative number, that number is interpreted as relative
- to one greater than the maximum index of _n_a_m_e, so negative indices
+ 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. When assigning to an indexed array, if _n_a_m_e is sub-
+ scripted by a negative number, that number is interpreted as relative
+ to one greater than the maximum index of _n_a_m_e, so negative indices
count back from the end of the array, and an index of -1 references the
last element.
- Any element of an array may be referenced using ${_n_a_m_e[_s_u_b_s_c_r_i_p_t]}.
+ 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
+ _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
+ 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. If the double-quoted expansion occurs within a word, the
- expansion of the first parameter is joined with the beginning part of
- the original word, and the expansion of the last parameter is joined
- with the last part of the original word. 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 expansion is the number of ele-
- ments in the array. If the _s_u_b_s_c_r_i_p_t used to reference an element of
- an indexed array evaluates to a number less than zero, it is inter-
- preted as relative to one greater than the maximum index of the array,
- so negative indices count back from the end of the array, and an index
+ arate word. When there are no array members, ${_n_a_m_e[@]} expands to
+ nothing. If the double-quoted expansion occurs within a word, the
+ expansion of the first parameter is joined with the beginning part of
+ the original word, and the expansion of the last parameter is joined
+ with the last part of the original word. 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 expansion is the number of ele-
+ ments in the array. If the _s_u_b_s_c_r_i_p_t used to reference an element of
+ an indexed array evaluates to a number less than zero, it is inter-
+ preted as relative to one greater than the maximum index of the array,
+ so negative indices count back from the end of the array, and an index
of -1 references the last element.
Referencing an array variable without a subscript is equivalent to ref-
- erencing the array with a subscript of 0. Any reference to a variable
+ erencing the array with a subscript of 0. Any reference to a variable
using a valid subscript is legal, and bbaasshh will create an array if nec-
essary.
- An array variable is considered set if a subscript has been assigned a
+ An array variable is considered set if a subscript has been assigned a
value. The null string is a valid value.
- It is possible to obtain the keys (indices) of an array as well as the
- values. ${!!_n_a_m_e[_@]} and ${!!_n_a_m_e[_*]} expand to the indices assigned in
+ It is possible to obtain the keys (indices) of an array as well as the
+ values. ${!!_n_a_m_e[_@]} and ${!!_n_a_m_e[_*]} expand to the indices assigned in
array variable _n_a_m_e. The treatment when in double quotes is similar to
the expansion of the special parameters _@ and _* within double quotes.
- 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. Negative subscripts to
- indexed arrays are interpreted as described above. Care must be taken
- to avoid unwanted side effects caused by pathname expansion. uunnsseett
+ 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. Negative subscripts to
+ indexed arrays are interpreted as described above. Care must be taken
+ to avoid unwanted side effects caused by pathname expansion. 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 indexed array and a --AA option to specify an associative
- array. If both options are supplied, --AA takes precedence. The rreeaadd
- builtin accepts a --aa option to assign a list of words read from the
+ The ddeeccllaarree, llooccaall, and rreeaaddoonnllyy builtins each accept a --aa option to
+ specify an indexed array and a --AA option to specify an associative
+ array. If both options are supplied, --AA takes precedence. 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_-
+ 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, parameter
- and variable expansion, arithmetic expansion, and command substitution
- (done in a left-to-right fashion); word splitting; and pathname expan-
+ and variable expansion, arithmetic expansion, and command substitution
+ (done in a left-to-right fashion); word splitting; and pathname expan-
sion.
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. This is performed at the same time as
- tilde, parameter, variable, and arithmetic expansion and command sub-
+ able: _p_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n. This is performed at the same time as
+ tilde, parameter, variable, and arithmetic expansion and command sub-
stitution.
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
+ 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-
+ 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
+ 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,
+ 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[[...._i_n_c_r]]}}, where _x and _y are
- either integers or single characters, and _i_n_c_r, an optional increment,
- is an integer. When integers are supplied, the expression expands to
- each number between _x and _y, inclusive. Supplied integers may be pre-
- fixed with _0 to force each term to have the same width. When either _x
- or _y begins with a zero, the shell attempts to force all generated
- terms to contain the same number of digits, zero-padding where neces-
- sary. When characters are supplied, the expression expands to each
- character lexicographically between _x and _y, inclusive, using the
- default C locale. Note that both _x and _y must be of the same type.
- When the increment is supplied, it is used as the difference between
+ A sequence expression takes the form {{_x...._y[[...._i_n_c_r]]}}, where _x and _y are
+ either integers or single characters, and _i_n_c_r, an optional increment,
+ is an integer. When integers are supplied, the expression expands to
+ each number between _x and _y, inclusive. Supplied integers may be pre-
+ fixed with _0 to force each term to have the same width. When either _x
+ or _y begins with a zero, the shell attempts to force all generated
+ terms to contain the same number of digits, zero-padding where neces-
+ sary. When characters are supplied, the expression expands to each
+ character lexicographically between _x and _y, inclusive, using the
+ default C locale. Note that both _x and _y must be of the same type.
+ When the increment is supplied, it is used as the difference between
each term. The default increment is 1 or -1 as appropriate.
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
+ 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 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-
+ 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
@@ -1496,36 +1497,36 @@ EEXXPPAANNSSIIOONN
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
+ 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
+ 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
+ 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
+ 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-
+ 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
@@ -1533,235 +1534,235 @@ EEXXPPAANNSSIIOONN
Each variable assignment is checked for unquoted tilde-prefixes immedi-
ately following a :: or the first ==. In these cases, tilde expansion is
- also performed. Consequently, one may use filenames with tildes in
- assignments to PPAATTHH, MMAAIILLPPAATTHH, and CCDDPPAATTHH, and the shell assigns the
+ also performed. Consequently, one may use filenames with tildes in
+ assignments 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
+ 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
+ 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 parameter
expansion.
${_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
+ 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. The _p_a_r_a_m_e_t_e_r is a shell
- parameter as described above PPAARRAAMMEETTEERRSS) or an array reference
+ parameter as described above PPAARRAAMMEETTEERRSS) or an array reference
(AArrrraayyss).
- If the first character of _p_a_r_a_m_e_t_e_r is an exclamation point (!!), and
- _p_a_r_a_m_e_t_e_r is not a _n_a_m_e_r_e_f, it introduces a level of variable indirec-
- tion. BBaasshh uses the value of the variable 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
+ If the first character of _p_a_r_a_m_e_t_e_r is an exclamation point (!!), and
+ _p_a_r_a_m_e_t_e_r is not a _n_a_m_e_r_e_f, it introduces a level of variable indirec-
+ tion. BBaasshh uses the value of the variable 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. If
+ 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. If
_p_a_r_a_m_e_t_e_r is a nameref, this expands to the name of the variable refer-
- enced by _p_a_r_a_m_e_t_e_r instead of performing the complete indirect expan-
- sion. 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
+ enced by _p_a_r_a_m_e_t_e_r instead of performing the complete indirect expan-
+ sion. 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 indirection.
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, using the forms documented
- below (e.g., ::--), bbaasshh tests for a parameter that is unset or null.
- Omitting the colon results in a test only for a parameter that is
+ When not performing substring expansion, using the forms documented
+ below (e.g., ::--), bbaasshh tests for a parameter that is unset or null.
+ Omitting the colon results in a test only for a parameter 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
+ 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
+ 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
+ _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
+ 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
+ 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 the
- value of _p_a_r_a_m_e_t_e_r starting at the character specified by _o_f_f_-
+ SSuubbssttrriinngg EExxppaannssiioonn. Expands to up to _l_e_n_g_t_h characters of the
+ value of _p_a_r_a_m_e_t_e_r starting at the character specified by _o_f_f_-
_s_e_t. If _p_a_r_a_m_e_t_e_r is @@, an indexed array subscripted by @@ or **,
- or an associative array name, the results differ as described
- below. If _l_e_n_g_t_h is omitted, expands to the substring of the
+ or an associative array name, the results differ as described
+ below. If _l_e_n_g_t_h is omitted, expands to the substring of the
value of _p_a_r_a_m_e_t_e_r starting at the character specified by _o_f_f_s_e_t
- and extending to the end of the value. _l_e_n_g_t_h and _o_f_f_s_e_t are
+ and extending to the end of the value. _l_e_n_g_t_h and _o_f_f_s_e_t are
arithmetic expressions (see AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN below).
- If _o_f_f_s_e_t evaluates to a number less than zero, the value is
- used as an offset in characters from the end of the value of
- _p_a_r_a_m_e_t_e_r. If _l_e_n_g_t_h evaluates to a number less than zero, it
- is interpreted as an offset in characters from the end of the
- value of _p_a_r_a_m_e_t_e_r rather than a number of characters, and the
- expansion is the characters between _o_f_f_s_e_t and that result.
- Note that a negative offset must be separated from the colon by
- at least one space to avoid being confused with the ::-- expan-
+ If _o_f_f_s_e_t evaluates to a number less than zero, the value is
+ used as an offset in characters from the end of the value of
+ _p_a_r_a_m_e_t_e_r. If _l_e_n_g_t_h evaluates to a number less than zero, it
+ is interpreted as an offset in characters from the end of the
+ value of _p_a_r_a_m_e_t_e_r rather than a number of characters, and the
+ expansion is the characters between _o_f_f_s_e_t and that result.
+ Note that a negative offset must be separated from the colon by
+ at least one space to avoid being confused with the ::-- expan-
sion.
- If _p_a_r_a_m_e_t_e_r is @@, the result is _l_e_n_g_t_h positional parameters
+ 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. A negative _o_f_f_s_e_t is taken relative to one
- greater than the greatest positional parameter, so an offset of
- -1 evaluates to the last positional parameter. It is an expan-
+ greater than the greatest positional parameter, so an offset of
+ -1 evaluates to the last positional parameter. It is an expan-
sion error if _l_e_n_g_t_h evaluates to a number less than zero.
If _p_a_r_a_m_e_t_e_r is an indexed array name subscripted 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]}. A negative _o_f_f_s_e_t is taken relative to
- one greater than the maximum index of the specified array. It
- is an expansion error if _l_e_n_g_t_h evaluates to a number less than
+ 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]}. A negative _o_f_f_s_e_t is taken relative to
+ one greater than the maximum index of the specified array. It
+ is an expansion error if _l_e_n_g_t_h evaluates to a number less than
zero.
- Substring expansion applied to an associative array produces
+ Substring expansion applied to an associative array produces
undefined results.
- Substring indexing is zero-based unless the positional parame-
- ters are used, in which case the indexing starts at 1 by
- default. If _o_f_f_s_e_t is 0, and the positional parameters are
+ Substring indexing is zero-based unless the positional parame-
+ ters are used, in which case the indexing starts at 1 by
+ default. If _o_f_f_s_e_t is 0, and the positional parameters are
used, $$00 is prefixed to the list.
${!!_p_r_e_f_i_x**}
${!!_p_r_e_f_i_x@@}
- NNaammeess mmaattcchhiinngg pprreeffiixx. Expands to the names of variables whose
+ NNaammeess mmaattcchhiinngg pprreeffiixx. 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. When _@ is used and the expansion appears
- within double quotes, each variable name expands to a separate
+ IIFFSS special variable. When _@ is used and the expansion appears
+ within double quotes, each variable name expands to a separate
word.
${!!_n_a_m_e[_@]}
${!!_n_a_m_e[_*]}
- LLiisstt ooff aarrrraayy kkeeyyss. 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,
+ LLiisstt ooff aarrrraayy kkeeyyss. 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}
- PPaarraammeetteerr lleennggtthh. The length in characters of the value of
- _p_a_r_a_m_e_t_e_r is substituted. 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 substi-
- tuted is the number of elements in the array. If _p_a_r_a_m_e_t_e_r is
- an indexed array name subscripted by a negative number, that
- number is interpreted as relative to one greater than the maxi-
- mum index of _p_a_r_a_m_e_t_e_r, so negative indices count back from the
- end of the array, and an index of -1 references the last ele-
+ PPaarraammeetteerr lleennggtthh. The length in characters of the value of
+ _p_a_r_a_m_e_t_e_r is substituted. 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 substi-
+ tuted is the number of elements in the array. If _p_a_r_a_m_e_t_e_r is
+ an indexed array name subscripted by a negative number, that
+ number is interpreted as relative to one greater than the maxi-
+ mum index of _p_a_r_a_m_e_t_e_r, so negative indices count back from the
+ end of the array, and an index of -1 references the last ele-
ment.
${_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}
RReemmoovvee mmaattcchhiinngg pprreeffiixx ppaatttteerrnn. 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 pat-
- tern (the ``####'' case) deleted. If _p_a_r_a_m_e_t_e_r is @@ or **, the
- pattern removal operation is applied to each positional parame-
+ 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 pat-
+ tern (the ``####'' case) deleted. If _p_a_r_a_m_e_t_e_r is @@ or **, the
+ pattern removal operation is applied to each positional parame-
ter 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
+ _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}
RReemmoovvee mmaattcchhiinngg ssuuffffiixx ppaatttteerrnn. 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 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 posi-
- tional 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
+ 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 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 posi-
+ tional 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}
PPaatttteerrnn ssuubbssttiittuuttiioonn. The _p_a_t_t_e_r_n is expanded to produce a pat-
- tern 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. If _p_a_t_t_e_r_n begins with //, all matches of _p_a_t_t_e_r_n are
- replaced with _s_t_r_i_n_g. Normally only the first match is
+ tern 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. If _p_a_t_t_e_r_n begins with //, all matches of _p_a_t_t_e_r_n are
+ replaced with _s_t_r_i_n_g. Normally only the first match is
replaced. If _p_a_t_t_e_r_n begins with ##, it must match at the begin-
ning 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.
+ %%, 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 // fol-
- lowing _p_a_t_t_e_r_n may be omitted. If the nnooccaasseemmaattcchh shell option
+ lowing _p_a_t_t_e_r_n may be omitted. If the nnooccaasseemmaattcchh shell option
is enabled, the match is performed without regard to the case of
alphabetic characters. 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 expansion 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
+ 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 substitution 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}
${_p_a_r_a_m_e_t_e_r^^^^_p_a_t_t_e_r_n}
${_p_a_r_a_m_e_t_e_r,,_p_a_t_t_e_r_n}
${_p_a_r_a_m_e_t_e_r,,,,_p_a_t_t_e_r_n}
- CCaassee mmooddiiffiiccaattiioonn. This expansion modifies the case of alpha-
- betic characters in _p_a_r_a_m_e_t_e_r. The _p_a_t_t_e_r_n is expanded to pro-
+ CCaassee mmooddiiffiiccaattiioonn. This expansion modifies the case of alpha-
+ betic characters in _p_a_r_a_m_e_t_e_r. The _p_a_t_t_e_r_n is expanded to pro-
duce a pattern just as in pathname expansion. Each character in
- the expanded value of _p_a_r_a_m_e_t_e_r is tested against _p_a_t_t_e_r_n, and,
- if it matches the pattern, its case is converted. The pattern
- should not attempt to match more than one character. The ^^
- operator converts lowercase letters matching _p_a_t_t_e_r_n to upper-
+ the expanded value of _p_a_r_a_m_e_t_e_r is tested against _p_a_t_t_e_r_n, and,
+ if it matches the pattern, its case is converted. The pattern
+ should not attempt to match more than one character. The ^^
+ operator converts lowercase letters matching _p_a_t_t_e_r_n to upper-
case; the ,, operator converts matching uppercase letters to low-
ercase. The ^^^^ and ,,,, expansions convert each matched character
- in the expanded value; the ^^ and ,, expansions match and convert
- only the first character in the expanded value. If _p_a_t_t_e_r_n is
- omitted, it is treated like a ??, which matches every character.
- If _p_a_r_a_m_e_t_e_r is @@ or **, the case modification 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 sub-
+ in the expanded value; the ^^ and ,, expansions match and convert
+ only the first character in the expanded value. If _p_a_t_t_e_r_n is
+ omitted, it is treated like a ??, which matches every character.
+ If _p_a_r_a_m_e_t_e_r is @@ or **, the case modification 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 sub-
scripted with @@ or **, the case modification operation is applied
- to each member of the array in turn, and the expansion is the
+ to each member of the array in turn, and the expansion is the
resultant list.
${_p_a_r_a_m_e_t_e_r@@_o_p_e_r_a_t_o_r}
PPaarraammeetteerr ttrraannssffoorrmmaattiioonn. The expansion is either a transforma-
- tion of the value of _p_a_r_a_m_e_t_e_r or information about _p_a_r_a_m_e_t_e_r
- itself, depending on the value of _o_p_e_r_a_t_o_r. Each _o_p_e_r_a_t_o_r is a
+ tion of the value of _p_a_r_a_m_e_t_e_r or information about _p_a_r_a_m_e_t_e_r
+ itself, depending on the value of _o_p_e_r_a_t_o_r. Each _o_p_e_r_a_t_o_r is a
single letter:
- QQ The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r
+ QQ The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r
quoted in a format that can be reused as input.
- EE The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r
- with backslash escape sequences expanded as with the
+ EE The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r
+ with backslash escape sequences expanded as with the
$$''......'' quoting mechansim.
PP The expansion is a string that is the result of expanding
the value of _p_a_r_a_m_e_t_e_r as if it were a prompt string (see
PPRROOMMPPTTIINNGG below).
- AA The expansion is a string in the form of an assignment
- statement or ddeeccllaarree command that, if evaluated, will
+ AA The expansion is a string in the form of an assignment
+ statement or ddeeccllaarree command that, if evaluated, will
recreate _p_a_r_a_m_e_t_e_r with its attributes and value.
- aa The expansion is a string consisting of flag values rep-
+ aa The expansion is a string consisting of flag values rep-
resenting _p_a_r_a_m_e_t_e_r's attributes.
- If _p_a_r_a_m_e_t_e_r is @@ or **, the operation is applied to each posi-
- tional 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 case modification operation is applied to each member of
+ If _p_a_r_a_m_e_t_e_r is @@ or **, the operation is applied to each posi-
+ tional 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 case modification operation is applied to each member of
the array in turn, and the expansion is the resultant list.
- The result of the expansion is subject to word splitting and
+ The result of the expansion is subject to word splitting and
pathname expansion as described below.
CCoommmmaanndd SSuubbssttiittuuttiioonn
@@ -1775,174 +1776,174 @@ EEXXPPAANNSSIIOONN
BBaasshh performs the expansion by executing _c_o_m_m_a_n_d in a subshell environ-
ment and replacing the command 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 com-
- mand substitution $$((ccaatt _f_i_l_e)) can be replaced by the equivalent but
+ not deleted, but they may be removed during word splitting. The com-
+ mand 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
+ 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
+ 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
+ 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-
+ 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
+ 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 and variable expansion, com-
- mand substitution, and quote removal. The result is treated as the
- arithmetic expression to be evaluated. Arithmetic expansions may be
+ mand substitution, and quote removal. The result is treated as the
+ arithmetic expression to be evaluated. Arithmetic expansions may be
nested.
- The evaluation is performed according to the rules listed below under
+ 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 allows a process's input or output to be referred
- to using a filename. It takes the form of <<((_l_i_s_t)) or >>((_l_i_s_t)). The
- process _l_i_s_t is run asynchronously, and its input or output appears as
+ _P_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n allows a process's input or output to be referred
+ to using a filename. It takes the form of <<((_l_i_s_t)) or >>((_l_i_s_t)). The
+ process _l_i_s_t is run asynchronously, and its input or output appears as
a filename. This filename is passed as an argument to the current com-
- mand as the result of the expansion. If the >>((_l_i_s_t)) form is used,
- writing to the file will provide 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
+ mand as the result of the expansion. If the >>((_l_i_s_t)) form is used,
+ writing to the file will provide 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. Process substitution is supported on systems that sup-
port named pipes (_F_I_F_O_s) or the //ddeevv//ffdd method of naming open files.
- When available, process substitution is performed simultaneously with
- parameter and variable expansion, command substitution, and arithmetic
+ 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
+ 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 using these characters as
- field terminators. If IIFFSS is unset, or its value is exactly
- <<ssppaaccee>><<ttaabb>><<nneewwlliinnee>>, the default, then sequences of <<ssppaaccee>>, <<ttaabb>>,
- and <<nneewwlliinnee>> at the beginning and end of the results of the previous
- expansions are ignored, and any sequence of IIFFSS characters not at the
- beginning or end serves to delimit words. If IIFFSS has a value other
- than the default, then sequences of the whitespace characters ssppaaccee,
- ttaabb, and nneewwlliinnee are ignored at the beginning and end of the word, as
- long as the whitespace character is in the value of IIFFSS (an IIFFSS white-
- space character). Any character in IIFFSS that is not IIFFSS whitespace,
+ The shell treats each character of IIFFSS as a delimiter, and splits the
+ results of the other expansions into words using these characters as
+ field terminators. If IIFFSS is unset, or its value is exactly
+ <<ssppaaccee>><<ttaabb>><<nneewwlliinnee>>, the default, then sequences of <<ssppaaccee>>, <<ttaabb>>,
+ and <<nneewwlliinnee>> at the beginning and end of the results of the previous
+ expansions are ignored, and any sequence of IIFFSS characters not at the
+ beginning or end serves to delimit words. If IIFFSS has a value other
+ than the default, then sequences of the whitespace characters ssppaaccee,
+ ttaabb, and nneewwlliinnee are ignored at the beginning and end of the word, as
+ long as the whitespace character is in the value of IIFFSS (an IIFFSS white-
+ space 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.
+ 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 and passed to commands
+ Explicit null arguments ("""" or '''') are retained and passed to commands
as empty strings. Unquoted implicit null arguments, resulting from the
expansion of parameters that have no values, are removed. If a parame-
- ter with no value is expanded within double quotes, a null argument
- results and is retained and passed to a command as an empty string.
- When a quoted null argument appears as part of a word whose expansion
- is non-null, the null argument is removed. That is, the word -d''
+ ter with no value is expanded within double quotes, a null argument
+ results and is retained and passed to a command as an empty string.
+ When a quoted null argument appears as part of a word whose expansion
+ is non-null, the null argument is removed. That is, the word -d''
becomes -d after word splitting and null argument removal.
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 filenames matching the pattern (see PPaatt--
- tteerrnn MMaattcchhiinngg below). If no matching filenames are found, and the
- shell option nnuullllgglloobb is not enabled, 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
+ 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 filenames matching the pattern (see PPaatt--
+ tteerrnn MMaattcchhiinngg below). If no matching filenames are found, and the
+ shell option nnuullllgglloobb is not enabled, 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 alphabetic 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
+ the shell option nnooccaasseegglloobb is enabled, the match is performed without
+ regard to the case of alphabetic 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 char-
- acter must always be matched explicitly. In other cases, the ````..''''
+ acter 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, nnuullll--
gglloobb, ffaaiillgglloobb, and ddoottgglloobb shell options.
- The GGLLOOBBIIGGNNOORREE shell variable may be used to restrict the set of file-
+ 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 filename
that also matches one of the patterns in GGLLOOBBIIGGNNOORREE is removed from the
list of matches. If the nnooccaasseegglloobb option is set, the matching against
- the patterns in GGLLOOBBIIGGNNOORREE is performed without regard to case. The
- filenames ````..'''' and ````....'''' are always ignored when GGLLOOBBIIGGNNOORREE is set
- and not null. However, setting GGLLOOBBIIGGNNOORREE to a non-null value has the
- effect of enabling the ddoottgglloobb shell option, so all other filenames
- beginning with a ````..'''' will match. To get the old behavior of ignor-
- ing filenames beginning with a ````..'''', make ````..**'''' one of the patterns
- in GGLLOOBBIIGGNNOORREE. The ddoottgglloobb option is disabled when GGLLOOBBIIGGNNOORREE is
- unset. The pattern matching honors the setting of the eexxttgglloobb shell
+ the patterns in GGLLOOBBIIGGNNOORREE is performed without regard to case. The
+ filenames ````..'''' and ````....'''' are always ignored when GGLLOOBBIIGGNNOORREE is set
+ and not null. However, setting GGLLOOBBIIGGNNOORREE to a non-null value has the
+ effect of enabling the ddoottgglloobb shell option, so all other filenames
+ beginning with a ````..'''' will match. To get the old behavior of ignor-
+ ing filenames beginning with a ````..'''', make ````..**'''' one of the patterns
+ in GGLLOOBBIIGGNNOORREE. The ddoottgglloobb option is disabled when GGLLOOBBIIGGNNOORREE is
+ unset. The pattern matching honors the setting of the eexxttgglloobb shell
option.
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 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. When the
- gglloobbssttaarr shell option is enabled, and ** is used in a
- pathname expansion context, two adjacent **s used as a
- single pattern will match all files and zero or more
- directories and subdirectories. If followed by a //, two
- adjacent **s will match only directories and subdirecto-
+ ** Matches any string, including the null string. When the
+ gglloobbssttaarr shell option is enabled, and ** is used in a
+ pathname expansion context, two adjacent **s used as a
+ single pattern will match all files and zero or more
+ directories and subdirectories. If followed by a //, two
+ adjacent **s will match only directories and subdirecto-
ries.
?? Matches any single character.
- [[......]] Matches any one of the enclosed characters. A pair of
- characters separated by a hyphen denotes a _r_a_n_g_e _e_x_p_r_e_s_-
- _s_i_o_n; any character that falls between those two charac-
- ters, inclusive, using the current locale's collating
- sequence and character set, is matched. If the first
+ [[......]] Matches any one of the enclosed characters. A pair of
+ characters separated by a hyphen denotes a _r_a_n_g_e _e_x_p_r_e_s_-
+ _s_i_o_n; any character that falls between those two charac-
+ ters, 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 charac-
- ter not enclosed is matched. The sorting order of char-
- acters in range expressions is determined by the current
- locale and the values of the LLCC__CCOOLLLLAATTEE or LLCC__AALLLL shell
+ ter not enclosed is matched. The sorting order of char-
+ acters in range expressions is determined by the current
+ locale and the values of the LLCC__CCOOLLLLAATTEE or LLCC__AALLLL shell
variables, if set. To obtain the traditional interpreta-
- tion of range expressions, where [[aa--dd]] is equivalent to
- [[aabbccdd]], set value of the LLCC__AALLLL shell variable to CC, or
- enable the gglloobbaasscciiiirraannggeess shell option. A -- may be
+ tion of range expressions, where [[aa--dd]] is equivalent to
+ [[aabbccdd]], set value of the LLCC__AALLLL shell variable to CC, or
+ enable the gglloobbaasscciiiirraannggeess shell option. A -- may be
matched by including it as the first or last character 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
+ 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 standard:
- aallnnuumm aallpphhaa aasscciiii bbllaannkk ccnnttrrll ddiiggiitt ggrraapphh lloowweerr pprriinntt
+ 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 character _.
- Within [[ and ]], an _e_q_u_i_v_a_l_e_n_c_e _c_l_a_s_s can be specified
+ 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 collation weight (as defined by the current
+ the same collation weight (as defined by the current
locale) as the character _c.
Within [[ and ]], the syntax [[.._s_y_m_b_o_l..]] matches the collat-
ing symbol _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
+ 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:
@@ -1960,55 +1961,58 @@ EEXXPPAANNSSIIOONN
QQuuoottee RReemmoovvaall
After the preceding expansions, all unquoted occurrences of the charac-
- ters \\, '', and "" that did not result from one of the above expansions
+ 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 allows
- commands' file handles to be duplicated, opened, closed, made to refer
+ 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 allows
+ commands' file handles to be duplicated, opened, closed, made to refer
to different files, and can change the files the command reads from and
- writes to. Redirection may also be used to modify file handles in the
- current shell execution environment. The following redirection opera-
+ writes to. Redirection may also be used to modify file handles in the
+ current shell execution environment. The following redirection opera-
tors may precede or appear anywhere within a _s_i_m_p_l_e _c_o_m_m_a_n_d or may fol-
- low a _c_o_m_m_a_n_d. Redirections are processed in the order they appear,
+ low a _c_o_m_m_a_n_d. Redirections are processed in the order they appear,
from left to right.
- Each redirection that may be preceded by a file descriptor number may
+ Each redirection that may be preceded by a file descriptor number may
instead be preceded by a word of the form {_v_a_r_n_a_m_e}. In this case, for
each redirection operator except >&- and <&-, the shell will allocate a
- file descriptor greater than or equal to 10 and assign it to _v_a_r_n_a_m_e.
- If >&- or <&- is preceded by {_v_a_r_n_a_m_e}, the value of _v_a_r_n_a_m_e defines
+ file descriptor greater than or equal to 10 and assign it to _v_a_r_n_a_m_e.
+ If >&- or <&- is preceded by {_v_a_r_n_a_m_e}, the value of _v_a_r_n_a_m_e defines
the file descriptor to close.
- In the following descriptions, if the file descriptor number is omit-
- ted, and the first character of the redirection operator is <<, the re-
- direction refers to the standard input (file descriptor 0). If the
- first character of the redirection operator is >>, the redirection
+ In the following descriptions, if the file descriptor number is omit-
+ ted, and the first character of the redirection operator is <<, the re-
+ direction 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 and variable expansion, command substitution,
- arithmetic expansion, quote removal, pathname expansion, and word
+ The word following the redirection operator in the following descrip-
+ tions, unless otherwise noted, is subjected to brace expansion, tilde
+ expansion, parameter and variable expansion, command substitution,
+ arithmetic expansion, 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
+ 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,
+ 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 from the standard output before the standard out-
+ directs only the standard output to file _d_i_r_l_i_s_t, because the standard
+ error was duplicated from the standard output before the standard out-
put 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:
+ tions, as described in the following table. If the operating system on
+ which bbaasshh is running provides these special files, bash will use them;
+ otherwise it will emulate them internally with the behavior described
+ below.
//ddeevv//ffdd//_f_d
If _f_d is a valid integer, file descriptor _f_d is dupli-