mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-02 08:18:14 +02:00
commit bash-20080626 snapshot
This commit is contained in:
+53
-19
@@ -5,12 +5,12 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@po.cwru.edu
|
||||
.\"
|
||||
.\" Last Change: Mon Jun 2 20:32:53 EDT 2008
|
||||
.\" Last Change: Sun Jun 29 22:44:15 EDT 2008
|
||||
.\"
|
||||
.\" bash_builtins, strip all but Built-Ins section
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2008 June 2" "GNU Bash-4.0"
|
||||
.TH BASH 1 "2008 June 29" "GNU Bash-4.0"
|
||||
.\"
|
||||
.\" There's some problem with having a `@'
|
||||
.\" in a tagged paragraph with the BSD man macros.
|
||||
@@ -1130,7 +1130,9 @@ When += is applied to an array variable using compound assignment (see
|
||||
.B Arrays
|
||||
below), the
|
||||
variable's value is not unset (as it is when using =), and new values are
|
||||
appended to the array beginning at one greater than the array's maximum index.
|
||||
appended to the array beginning at one greater than the array's maximum index
|
||||
(for indexed arrays) or added as additional key\-value pairs in an
|
||||
associative array.
|
||||
When applied to a string-valued variable, \fIvalue\fP is expanded and
|
||||
appended to the variable's value.
|
||||
.SS Positional Parameters
|
||||
@@ -1264,6 +1266,12 @@ Expands to the process id of the current \fBbash\fP process.
|
||||
This differs from \fB$$\fP under certain circumstances, such as subshells
|
||||
that do not require \fBbash\fP to be re-initialized.
|
||||
.TP
|
||||
.B BASH_ALIASES
|
||||
An associative array variable whose members correspond to the internal
|
||||
list of aliases as maintained by the \fBalias\fP builtin
|
||||
Elements added to this array appear in the alias list; unsetting array
|
||||
elements cause aliases to be removed from the alias list.
|
||||
.TP
|
||||
.B BASH_ARGC
|
||||
An array variable whose values are the number of parameters in each
|
||||
frame of the current \fBbash\fP execution call stack.
|
||||
@@ -1292,6 +1300,12 @@ option to the
|
||||
.B shopt
|
||||
builtin below)
|
||||
.TP
|
||||
.B BASH_CMDS
|
||||
An associative array variable whose members correspond to the internal
|
||||
hash table of commands as maintained by the \fBhash\fP builtin.
|
||||
Elements added to this array appear in the hash table; unsetting array
|
||||
elements cause commands to be removed from the hash table.
|
||||
.TP
|
||||
.B BASH_COMMAND
|
||||
The command currently being executed or about to be executed, unless the
|
||||
shell is executing a command as the result of a trap,
|
||||
@@ -2101,19 +2115,23 @@ parser to treat the rest of the line as a comment.
|
||||
.PD
|
||||
.SS Arrays
|
||||
.B Bash
|
||||
provides one-dimensional array variables. Any variable may be used as
|
||||
an array; the
|
||||
provides one-dimensional indexed and associative array variables.
|
||||
Any variable may be used as an array; the
|
||||
.B declare
|
||||
builtin will explicitly declare an array. There is no maximum
|
||||
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.
|
||||
be indexed or assigned contiguously.
|
||||
Indexed arrays are referenced using integers (including arithmetic
|
||||
expressions) and are zero-based; associative arrays use arbitrary
|
||||
strings.
|
||||
.PP
|
||||
An array is created automatically if any variable is assigned to using
|
||||
the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
|
||||
An indexed array is created automatically if any variable is assigned to
|
||||
using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
|
||||
.I subscript
|
||||
is treated as an arithmetic expression that must evaluate to a number
|
||||
greater than or equal to zero. To explicitly declare an array, use
|
||||
greater than or equal to zero. To explicitly declare an indexed array,
|
||||
use
|
||||
.B declare \-a \fIname\fP
|
||||
(see
|
||||
.SM
|
||||
@@ -2127,13 +2145,19 @@ and
|
||||
.B readonly
|
||||
builtins. Each attribute applies to all members of an array.
|
||||
.PP
|
||||
Associative arrays are created using
|
||||
.BR declare \-A \fIname\fP .
|
||||
.PP
|
||||
Arrays are assigned to using compound assignments of the form
|
||||
\fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
|
||||
\fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
|
||||
\fIstring\fP is required. If
|
||||
\fIstring\fP is required. When using 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 plus one. Indexing starts at zero.
|
||||
.PP
|
||||
When assigning to an associative array, the subscript is required.
|
||||
.PP
|
||||
This syntax is also accepted by the
|
||||
.B declare
|
||||
builtin. Individual array elements may be assigned to using the
|
||||
@@ -2164,7 +2188,7 @@ above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
|
||||
${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
|
||||
\fB@\fP, the expansion is the number of elements in the array.
|
||||
Referencing an array variable without a subscript is equivalent to
|
||||
referencing element zero.
|
||||
referencing the array with a subscript of 0.
|
||||
.PP
|
||||
The
|
||||
.B unset
|
||||
@@ -2183,7 +2207,10 @@ and
|
||||
.B readonly
|
||||
builtins each accept a
|
||||
.B \-a
|
||||
option to specify an array. The
|
||||
option to specify an indexed array and a
|
||||
.B \-A
|
||||
option to specify an associative array.
|
||||
The
|
||||
.B read
|
||||
builtin accepts a
|
||||
.B \-a
|
||||
@@ -6618,10 +6645,10 @@ is greater than the number of enclosing loops, the last enclosing loop
|
||||
(the ``top-level'' loop) is resumed.
|
||||
The return value is 0 unless \fIn\fP is not greater than or equal to 1.
|
||||
.TP
|
||||
\fBdeclare\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
||||
\fBdeclare\fP [\fB\-aAfFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
||||
.PD 0
|
||||
.TP
|
||||
\fBtypeset\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
||||
\fBtypeset\fP [\fB\-aAfFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
||||
.PD
|
||||
Declare variables and/or give them attributes.
|
||||
If no \fIname\fPs are given then display the values of variables.
|
||||
@@ -6657,7 +6684,12 @@ to give variables attributes:
|
||||
.PD 0
|
||||
.TP
|
||||
.B \-a
|
||||
Each \fIname\fP is an array variable (see
|
||||
Each \fIname\fP is an indexed array variable (see
|
||||
.B Arrays
|
||||
above).
|
||||
.TP
|
||||
.B \-A
|
||||
Each \fIname\fP is an associative array variable (see
|
||||
.B Arrays
|
||||
above).
|
||||
.TP
|
||||
@@ -7770,7 +7802,7 @@ times out, or an invalid file descriptor is supplied as the argument to
|
||||
\fB\-u\fP.
|
||||
.RE
|
||||
.TP
|
||||
\fBreadonly\fP [\fB\-apf\fP] [\fIname\fP[=\fIword\fP] ...]
|
||||
\fBreadonly\fP [\fB\-aApf\fP] [\fIname\fP[=\fIword\fP] ...]
|
||||
.PD
|
||||
The given
|
||||
\fInames\fP are marked readonly; the values of these
|
||||
@@ -7783,7 +7815,9 @@ option is supplied, the functions corresponding to the
|
||||
marked.
|
||||
The
|
||||
.B \-a
|
||||
option restricts the variables to arrays.
|
||||
option restricts the variables to indexed arrays; the
|
||||
.B \-A
|
||||
option restricts the variables to associative arrays.
|
||||
If no
|
||||
.I name
|
||||
arguments are given, or if the
|
||||
|
||||
+52
-17
@@ -1130,7 +1130,9 @@ When += is applied to an array variable using compound assignment (see
|
||||
.B Arrays
|
||||
below), the
|
||||
variable's value is not unset (as it is when using =), and new values are
|
||||
appended to the array beginning at one greater than the array's maximum index.
|
||||
appended to the array beginning at one greater than the array's maximum index
|
||||
(for indexed arrays) or added as additional key\-value pairs in an
|
||||
associative array.
|
||||
When applied to a string-valued variable, \fIvalue\fP is expanded and
|
||||
appended to the variable's value.
|
||||
.SS Positional Parameters
|
||||
@@ -1264,6 +1266,12 @@ Expands to the process id of the current \fBbash\fP process.
|
||||
This differs from \fB$$\fP under certain circumstances, such as subshells
|
||||
that do not require \fBbash\fP to be re-initialized.
|
||||
.TP
|
||||
.B BASH_ALIASES
|
||||
An associative array variable whose members correspond to the internal
|
||||
list of aliases as maintained by the \fBalias\fP builtin
|
||||
Elements added to this array appear in the alias list; unsetting array
|
||||
elements cause aliases to be removed from the alias list.
|
||||
.TP
|
||||
.B BASH_ARGC
|
||||
An array variable whose values are the number of parameters in each
|
||||
frame of the current \fBbash\fP execution call stack.
|
||||
@@ -1292,6 +1300,12 @@ option to the
|
||||
.B shopt
|
||||
builtin below)
|
||||
.TP
|
||||
.B BASH_CMDS
|
||||
An associative array variable whose members correspond to the internal
|
||||
hash table of commands as maintained by the \fBhash\fP builtin.
|
||||
Elements added to this array appear in the hash table; unsetting array
|
||||
elements cause commands to be removed from the hash table.
|
||||
.TP
|
||||
.B BASH_COMMAND
|
||||
The command currently being executed or about to be executed, unless the
|
||||
shell is executing a command as the result of a trap,
|
||||
@@ -2101,19 +2115,23 @@ parser to treat the rest of the line as a comment.
|
||||
.PD
|
||||
.SS Arrays
|
||||
.B Bash
|
||||
provides one-dimensional array variables. Any variable may be used as
|
||||
an array; the
|
||||
provides one-dimensional indexed and associative array variables.
|
||||
Any variable may be used as an array; the
|
||||
.B declare
|
||||
builtin will explicitly declare an array. There is no maximum
|
||||
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.
|
||||
be indexed or assigned contiguously.
|
||||
Indexed arrays are referenced using integers (including arithmetic
|
||||
expressions) and are zero-based; associative arrays use arbitrary
|
||||
strings.
|
||||
.PP
|
||||
An array is created automatically if any variable is assigned to using
|
||||
the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
|
||||
An indexed array is created automatically if any variable is assigned to
|
||||
using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The
|
||||
.I subscript
|
||||
is treated as an arithmetic expression that must evaluate to a number
|
||||
greater than or equal to zero. To explicitly declare an array, use
|
||||
greater than or equal to zero. To explicitly declare an indexed array,
|
||||
use
|
||||
.B declare \-a \fIname\fP
|
||||
(see
|
||||
.SM
|
||||
@@ -2127,13 +2145,19 @@ and
|
||||
.B readonly
|
||||
builtins. Each attribute applies to all members of an array.
|
||||
.PP
|
||||
Associative arrays are created using
|
||||
.BR declare \-A \fIname\fP .
|
||||
.PP
|
||||
Arrays are assigned to using compound assignments of the form
|
||||
\fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each
|
||||
\fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. Only
|
||||
\fIstring\fP is required. If
|
||||
\fIstring\fP is required. When using 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 plus one. Indexing starts at zero.
|
||||
.PP
|
||||
When assigning to an associative array, the subscript is required.
|
||||
.PP
|
||||
This syntax is also accepted by the
|
||||
.B declare
|
||||
builtin. Individual array elements may be assigned to using the
|
||||
@@ -2164,7 +2188,7 @@ above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of
|
||||
${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or
|
||||
\fB@\fP, the expansion is the number of elements in the array.
|
||||
Referencing an array variable without a subscript is equivalent to
|
||||
referencing element zero.
|
||||
referencing the array with a subscript of 0.
|
||||
.PP
|
||||
The
|
||||
.B unset
|
||||
@@ -2183,7 +2207,10 @@ and
|
||||
.B readonly
|
||||
builtins each accept a
|
||||
.B \-a
|
||||
option to specify an array. The
|
||||
option to specify an indexed array and a
|
||||
.B \-A
|
||||
option to specify an associative array.
|
||||
The
|
||||
.B read
|
||||
builtin accepts a
|
||||
.B \-a
|
||||
@@ -6618,10 +6645,10 @@ is greater than the number of enclosing loops, the last enclosing loop
|
||||
(the ``top-level'' loop) is resumed.
|
||||
The return value is 0 unless \fIn\fP is not greater than or equal to 1.
|
||||
.TP
|
||||
\fBdeclare\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
||||
\fBdeclare\fP [\fB\-aAfFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
||||
.PD 0
|
||||
.TP
|
||||
\fBtypeset\fP [\fB\-afFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
||||
\fBtypeset\fP [\fB\-aAfFirtx\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...]
|
||||
.PD
|
||||
Declare variables and/or give them attributes.
|
||||
If no \fIname\fPs are given then display the values of variables.
|
||||
@@ -6657,7 +6684,12 @@ to give variables attributes:
|
||||
.PD 0
|
||||
.TP
|
||||
.B \-a
|
||||
Each \fIname\fP is an array variable (see
|
||||
Each \fIname\fP is an indexed array variable (see
|
||||
.B Arrays
|
||||
above).
|
||||
.TP
|
||||
.B \-A
|
||||
Each \fIname\fP is an associative array variable (see
|
||||
.B Arrays
|
||||
above).
|
||||
.TP
|
||||
@@ -7754,6 +7786,7 @@ the decimal point.
|
||||
This option is only effective if \fBread\fP is reading input from a
|
||||
terminal, pipe, or other special file; it has no effect when reading
|
||||
from regular files.
|
||||
The exit status is greater than 128 if the timeout is exceeded.
|
||||
.TP
|
||||
.B \-u \fIfd\fP
|
||||
Read input from file descriptor \fIfd\fP.
|
||||
@@ -7769,7 +7802,7 @@ times out, or an invalid file descriptor is supplied as the argument to
|
||||
\fB\-u\fP.
|
||||
.RE
|
||||
.TP
|
||||
\fBreadonly\fP [\fB\-apf\fP] [\fIname\fP[=\fIword\fP] ...]
|
||||
\fBreadonly\fP [\fB\-aApf\fP] [\fIname\fP[=\fIword\fP] ...]
|
||||
.PD
|
||||
The given
|
||||
\fInames\fP are marked readonly; the values of these
|
||||
@@ -7782,7 +7815,9 @@ option is supplied, the functions corresponding to the
|
||||
marked.
|
||||
The
|
||||
.B \-a
|
||||
option restricts the variables to arrays.
|
||||
option restricts the variables to indexed arrays; the
|
||||
.B \-A
|
||||
option restricts the variables to associative arrays.
|
||||
If no
|
||||
.I name
|
||||
arguments are given, or if the
|
||||
|
||||
+56
-15
@@ -1234,7 +1234,8 @@ When @samp{+=} is applied to an array variable using compound assignment
|
||||
(@pxref{Arrays}), the
|
||||
variable's value is not unset (as it is when using @samp{=}), and new
|
||||
values are appended to the array beginning at one greater than the array's
|
||||
maximum index.
|
||||
maximum index (for indexed arrays), or added as additional key-value pairs
|
||||
in an associative array.
|
||||
When applied to a string-valued variable, @var{value} is expanded and
|
||||
appended to the variable's value.
|
||||
|
||||
@@ -2921,13 +2922,15 @@ is supplied.
|
||||
@item readonly
|
||||
@btindex readonly
|
||||
@example
|
||||
readonly [-apf] [@var{name}[=@var{value}]] @dots{}
|
||||
readonly [-aApf] [@var{name}[=@var{value}]] @dots{}
|
||||
@end example
|
||||
Mark each @var{name} as readonly.
|
||||
The values of these names may not be changed by subsequent assignment.
|
||||
If the @option{-f} option is supplied, each @var{name} refers to a shell
|
||||
function.
|
||||
The @option{-a} option means each @var{name} refers to an array variable.
|
||||
The @option{-a} option means each @var{name} refers to an indexed
|
||||
array variable; the @option{-A} option means each @var{name} refers
|
||||
to an associative array variable.
|
||||
If no @var{name} arguments are given, or if the @option{-p}
|
||||
option is supplied, a list of all readonly names is printed.
|
||||
The @option{-p} option causes output to be displayed in a format that
|
||||
@@ -3318,7 +3321,7 @@ zero if @var{command} is found, and non-zero if not.
|
||||
@item declare
|
||||
@btindex declare
|
||||
@example
|
||||
declare [-afFirtx] [-p] [@var{name}[=@var{value}] @dots{}]
|
||||
declare [-aAfFirtx] [-p] [@var{name}[=@var{value}] @dots{}]
|
||||
@end example
|
||||
|
||||
Declare variables and give them attributes. If no @var{name}s
|
||||
@@ -3347,7 +3350,10 @@ the specified attributes or to give variables attributes:
|
||||
|
||||
@table @code
|
||||
@item -a
|
||||
Each @var{name} is an array variable (@pxref{Arrays}).
|
||||
Each @var{name} is an indexed array variable (@pxref{Arrays}).
|
||||
|
||||
@item -A
|
||||
Each @var{name} is an associative array variable (@pxref{Arrays}).
|
||||
|
||||
@item -f
|
||||
Use function names only.
|
||||
@@ -4518,6 +4524,13 @@ Expands to the process id of the current Bash process.
|
||||
This differs from @code{$$} under certain circumstances, such as subshells
|
||||
that do not require Bash to be re-initialized.
|
||||
|
||||
@item BASH_ALIASES
|
||||
An associative array variable whose members correspond to the internal
|
||||
list of aliases as maintained by the @code{alias} builtin
|
||||
(@pxref{Bourne Shell Builtins}).
|
||||
Elements added to this array appear in the alias list; unsetting array
|
||||
elements cause aliases to be removed from the alias list.
|
||||
|
||||
@item BASH_ARGC
|
||||
An array variable whose values are the number of parameters in each
|
||||
frame of the current bash execution call stack. The number of
|
||||
@@ -4541,6 +4554,13 @@ The shell sets @code{BASH_ARGV} only when in extended debugging mode
|
||||
for a description of the @code{extdebug} option to the @code{shopt}
|
||||
builtin).
|
||||
|
||||
@item BASH_CMDS
|
||||
An associative array variable whose members correspond to the internal
|
||||
hash table of commands as maintained by the @code{hash} builtin
|
||||
(@pxref{Bourne Shell Builtins}).
|
||||
Elements added to this array appear in the hash table; unsetting array
|
||||
elements cause commands to be removed from the hash table.
|
||||
|
||||
@item BASH_COMMAND
|
||||
The command currently being executed or about to be executed, unless the
|
||||
shell is executing a command as the result of a trap,
|
||||
@@ -5807,14 +5827,18 @@ For almost every purpose, shell functions are preferred over aliases.
|
||||
@section Arrays
|
||||
@cindex arrays
|
||||
|
||||
Bash provides one-dimensional array variables. Any variable may be used as
|
||||
an array; the @code{declare} builtin will explicitly declare an array.
|
||||
Bash provides one-dimensional indexed and associative array variables.
|
||||
Any variable may be used as an array; the @code{declare} 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 zero-based.
|
||||
be indexed or assigned contiguously.
|
||||
Indexed arrays are referenced using integers (including arithmetic
|
||||
expressions (@pxref{Shell Arithmetic}) and are zero-based;
|
||||
associative arrays use arbitrary strings.
|
||||
|
||||
An array is created automatically if any variable is assigned to using
|
||||
the syntax
|
||||
An indexed array is created automatically if any variable is assigned to
|
||||
using the syntax
|
||||
@example
|
||||
name[@var{subscript}]=@var{value}
|
||||
@end example
|
||||
@@ -5837,16 +5861,25 @@ specified for an array variable using the @code{declare} and
|
||||
@code{readonly} builtins. Each attribute applies to all members of
|
||||
an array.
|
||||
|
||||
Associative arrays are created using
|
||||
@example
|
||||
declare -A @var{name}.
|
||||
@end example
|
||||
|
||||
Arrays are assigned to using compound assignments of the form
|
||||
@example
|
||||
name=(value@var{1} @dots{} value@var{n})
|
||||
@end example
|
||||
@noindent
|
||||
where each
|
||||
@var{value} is of the form @code{[[@var{subscript}]=]}@var{string}. If
|
||||
@var{value} is of the form @code{[[@var{subscript}]=]}@var{string}.
|
||||
When using indexed arrays, if
|
||||
the optional subscript is 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 @code{declare}
|
||||
builtin. Individual array elements may be assigned to using the
|
||||
@code{name[}@var{subscript}@code{]=}@var{value} syntax introduced above.
|
||||
@@ -5875,7 +5908,7 @@ expansion of the special parameters @samp{@@} and @samp{*}.
|
||||
If @var{subscript} is @samp{@@} or
|
||||
@samp{*}, the expansion is the number of elements in the array.
|
||||
Referencing an array variable without a subscript is equivalent to
|
||||
referencing element zero.
|
||||
referencing with a subscript of 0.
|
||||
|
||||
The @code{unset} builtin is used to destroy arrays.
|
||||
@code{unset} @var{name}[@var{subscript}]
|
||||
@@ -5887,9 +5920,9 @@ entire array. A subscript of @samp{*} or @samp{@@} also removes the
|
||||
entire array.
|
||||
|
||||
The @code{declare}, @code{local}, and @code{readonly}
|
||||
builtins each accept a @option{-a}
|
||||
option to specify an array. The @code{read}
|
||||
builtin accepts a @option{-a}
|
||||
builtins each accept a @option{-a} option to specify an indexed
|
||||
array and a @option{-A} option to specify an associative array.
|
||||
The @code{read} builtin accepts a @option{-a}
|
||||
option to assign a list of words read from the standard input
|
||||
to an array, and can read values from the standard input into
|
||||
individual array elements. The @code{set} and @code{declare}
|
||||
@@ -7020,6 +7053,14 @@ Include @code{csh}-like brace expansion
|
||||
( @code{b@{a,b@}c} @expansion{} @code{bac bbc} ).
|
||||
See @ref{Brace Expansion}, for a complete description.
|
||||
|
||||
@item --enable-casemod-attributes
|
||||
Include support for case-modifying attributes in the @code{declare} builtin
|
||||
and assignment statements. Variables with the @var{uppercase} attribute,
|
||||
for example, will have their values converted to uppercase upon assignment.
|
||||
|
||||
@item --enable-casemod-expansion
|
||||
Include support for case-modifying word expansions.
|
||||
|
||||
@item --enable-command-timing
|
||||
Include support for recognizing @code{time} as a reserved word and for
|
||||
displaying timing statistics for the pipeline following @code{time}
|
||||
|
||||
+57
-15
@@ -1234,7 +1234,8 @@ When @samp{+=} is applied to an array variable using compound assignment
|
||||
(@pxref{Arrays}), the
|
||||
variable's value is not unset (as it is when using @samp{=}), and new
|
||||
values are appended to the array beginning at one greater than the array's
|
||||
maximum index.
|
||||
maximum index (for indexed arrays), or added as additional key-value pairs
|
||||
in an associative array.
|
||||
When applied to a string-valued variable, @var{value} is expanded and
|
||||
appended to the variable's value.
|
||||
|
||||
@@ -2921,13 +2922,15 @@ is supplied.
|
||||
@item readonly
|
||||
@btindex readonly
|
||||
@example
|
||||
readonly [-apf] [@var{name}[=@var{value}]] @dots{}
|
||||
readonly [-aApf] [@var{name}[=@var{value}]] @dots{}
|
||||
@end example
|
||||
Mark each @var{name} as readonly.
|
||||
The values of these names may not be changed by subsequent assignment.
|
||||
If the @option{-f} option is supplied, each @var{name} refers to a shell
|
||||
function.
|
||||
The @option{-a} option means each @var{name} refers to an array variable.
|
||||
The @option{-a} option means each @var{name} refers to an indexed
|
||||
array variable; the @option{-A} option means each @var{name} refers
|
||||
to an associative array variable.
|
||||
If no @var{name} arguments are given, or if the @option{-p}
|
||||
option is supplied, a list of all readonly names is printed.
|
||||
The @option{-p} option causes output to be displayed in a format that
|
||||
@@ -3318,7 +3321,7 @@ zero if @var{command} is found, and non-zero if not.
|
||||
@item declare
|
||||
@btindex declare
|
||||
@example
|
||||
declare [-afFirtx] [-p] [@var{name}[=@var{value}] @dots{}]
|
||||
declare [-aAfFirtx] [-p] [@var{name}[=@var{value}] @dots{}]
|
||||
@end example
|
||||
|
||||
Declare variables and give them attributes. If no @var{name}s
|
||||
@@ -3347,7 +3350,10 @@ the specified attributes or to give variables attributes:
|
||||
|
||||
@table @code
|
||||
@item -a
|
||||
Each @var{name} is an array variable (@pxref{Arrays}).
|
||||
Each @var{name} is an indexed array variable (@pxref{Arrays}).
|
||||
|
||||
@item -A
|
||||
Each @var{name} is an associative array variable (@pxref{Arrays}).
|
||||
|
||||
@item -f
|
||||
Use function names only.
|
||||
@@ -3664,6 +3670,7 @@ the decimal point.
|
||||
This option is only effective if @code{read} is reading input from a
|
||||
terminal, pipe, or other special file; it has no effect when reading
|
||||
from regular files.
|
||||
The exit status is greater than 128 if the timeout is exceeded.
|
||||
|
||||
@item -u @var{fd}
|
||||
Read input from file descriptor @var{fd}.
|
||||
@@ -4517,6 +4524,13 @@ Expands to the process id of the current Bash process.
|
||||
This differs from @code{$$} under certain circumstances, such as subshells
|
||||
that do not require Bash to be re-initialized.
|
||||
|
||||
@item BASH_ALIASES
|
||||
An associative array variable whose members correspond to the internal
|
||||
list of aliases as maintained by the @code{alias} builtin
|
||||
(@pxref{Bourne Shell Builtins}).
|
||||
Elements added to this array appear in the alias list; unsetting array
|
||||
elements cause aliases to be removed from the alias list.
|
||||
|
||||
@item BASH_ARGC
|
||||
An array variable whose values are the number of parameters in each
|
||||
frame of the current bash execution call stack. The number of
|
||||
@@ -4540,6 +4554,13 @@ The shell sets @code{BASH_ARGV} only when in extended debugging mode
|
||||
for a description of the @code{extdebug} option to the @code{shopt}
|
||||
builtin).
|
||||
|
||||
@item BASH_CMDS
|
||||
An associative array variable whose members correspond to the internal
|
||||
hash table of commands as maintained by the @code{hash} builtin
|
||||
(@pxref{Bourne Shell Builtins}).
|
||||
Elements are to this array appear in the hash table; unsetting array
|
||||
elements cause commands to be removed from the hash table.
|
||||
|
||||
@item BASH_COMMAND
|
||||
The command currently being executed or about to be executed, unless the
|
||||
shell is executing a command as the result of a trap,
|
||||
@@ -5806,14 +5827,18 @@ For almost every purpose, shell functions are preferred over aliases.
|
||||
@section Arrays
|
||||
@cindex arrays
|
||||
|
||||
Bash provides one-dimensional array variables. Any variable may be used as
|
||||
an array; the @code{declare} builtin will explicitly declare an array.
|
||||
Bash provides one-dimensional indexed and associative array variables.
|
||||
Any variable may be used as an array; the @code{declare} 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 zero-based.
|
||||
be indexed or assigned contiguously.
|
||||
Indexed arrays are referenced using integers (including arithmetic
|
||||
expressions (@pxref{Shell Arithmetic}) and are zero-based;
|
||||
associative arrays use arbitrary strings.
|
||||
|
||||
An array is created automatically if any variable is assigned to using
|
||||
the syntax
|
||||
An indexed array is created automatically if any variable is assigned to
|
||||
using the syntax
|
||||
@example
|
||||
name[@var{subscript}]=@var{value}
|
||||
@end example
|
||||
@@ -5836,16 +5861,25 @@ specified for an array variable using the @code{declare} and
|
||||
@code{readonly} builtins. Each attribute applies to all members of
|
||||
an array.
|
||||
|
||||
Associative arrays are created using
|
||||
@example
|
||||
declare -A @var{name}.
|
||||
@end example
|
||||
|
||||
Arrays are assigned to using compound assignments of the form
|
||||
@example
|
||||
name=(value@var{1} @dots{} value@var{n})
|
||||
@end example
|
||||
@noindent
|
||||
where each
|
||||
@var{value} is of the form @code{[[@var{subscript}]=]}@var{string}. If
|
||||
@var{value} is of the form @code{[[@var{subscript}]=]}@var{string}.
|
||||
When using indexed arrays, if
|
||||
the optional subscript is 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 @code{declare}
|
||||
builtin. Individual array elements may be assigned to using the
|
||||
@code{name[}@var{subscript}@code{]=}@var{value} syntax introduced above.
|
||||
@@ -5874,7 +5908,7 @@ expansion of the special parameters @samp{@@} and @samp{*}.
|
||||
If @var{subscript} is @samp{@@} or
|
||||
@samp{*}, the expansion is the number of elements in the array.
|
||||
Referencing an array variable without a subscript is equivalent to
|
||||
referencing element zero.
|
||||
referencing with a subscript of 0.
|
||||
|
||||
The @code{unset} builtin is used to destroy arrays.
|
||||
@code{unset} @var{name}[@var{subscript}]
|
||||
@@ -5886,9 +5920,9 @@ entire array. A subscript of @samp{*} or @samp{@@} also removes the
|
||||
entire array.
|
||||
|
||||
The @code{declare}, @code{local}, and @code{readonly}
|
||||
builtins each accept a @option{-a}
|
||||
option to specify an array. The @code{read}
|
||||
builtin accepts a @option{-a}
|
||||
builtins each accept a @option{-a} option to specify an indexed
|
||||
array and a @option{-A} option to specify an associative array.
|
||||
The @code{read} builtin accepts a @option{-a}
|
||||
option to assign a list of words read from the standard input
|
||||
to an array, and can read values from the standard input into
|
||||
individual array elements. The @code{set} and @code{declare}
|
||||
@@ -7019,6 +7053,14 @@ Include @code{csh}-like brace expansion
|
||||
( @code{b@{a,b@}c} @expansion{} @code{bac bbc} ).
|
||||
See @ref{Brace Expansion}, for a complete description.
|
||||
|
||||
@item --enable-casemod-attributes
|
||||
Include support for case-modifying attributes in the @code{declare} builtin
|
||||
and assignment statements. Variables with the @var{uppercase} attribute,
|
||||
for example, will have their values converted to uppercase upon assignment.
|
||||
|
||||
@item --enable-casemod-expansion
|
||||
Include support for case-modifying word expansions.
|
||||
|
||||
@item --enable-command-timing
|
||||
Include support for recognizing @code{time} as a reserved word and for
|
||||
displaying timing statistics for the pipeline following @code{time}
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
Copyright (C) 1988-2008 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Mon Jun 2 20:32:28 EDT 2008
|
||||
@set LASTCHANGE Sun Jun 29 22:41:25 EDT 2008
|
||||
|
||||
@set EDITION 4.0
|
||||
@set VERSION 4.0
|
||||
@set UPDATED 2 June 2008
|
||||
@set UPDATED 29 June 2008
|
||||
@set UPDATED-MONTH June 2008
|
||||
|
||||
+3
-3
@@ -2,9 +2,9 @@
|
||||
Copyright (C) 1988-2008 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Sun May 25 10:48:26 EDT 2008
|
||||
@set LASTCHANGE Thu Jun 26 10:59:10 EDT 2008
|
||||
|
||||
@set EDITION 4.0
|
||||
@set VERSION 4.0
|
||||
@set UPDATED 25 May 2008
|
||||
@set UPDATED-MONTH May 2008
|
||||
@set UPDATED 26 June 2008
|
||||
@set UPDATED-MONTH June 2008
|
||||
|
||||
Reference in New Issue
Block a user