A parameter has a name, a value, and a number of attributes. A name may be any sequence of alphanumeric characters and _'s, or the single characters *, @, #, ?, -, $, or !. The value may be either a scalar (a string), an integer, or an array. To assign a scalar or integer value to a parameter, use the typeset builtin. To assign an array value, use
set -A name value ....
The value of a parameter may also be assigned by writing:
name=value ...
If the integer attribute, -i, is set for name, the value is subject to arithmetic evaluation.
The value of an array parameter may be assigned by writing:
name=(value ...) ...
Individual elements of an array may be selected using a subscript. A
subscript of the form [exp] selects the single element
exp, where exp is an arithmetic expression which will be
subject to arithmetic expansion as if it were surrounded by "$[...]".
The elements are numbered beginning with 1.
A subscript of the form [*] or [@] evaluates to all
elements of an array; there is no difference between the two except
when they appear within double quotes. "$foo[*]" evaluates
to "$foo[1] $foo[2] ...", while "$foo[@]"
evaluates to "$foo[1]" "$foo[2]", etc.
A subscript of the form [exp1,exp2]
selects all elements in the range exp1 to exp2,
inclusive. If one of the subscripts evaluates to a negative number,
say - n, then the nth element from the end of the array
is used. Thus "$foo[-3]" is the third element from the end
of the array foo, and "$foo[1,-1]" is the same as
"$foo[*]".
Subscripting may also be performed on non-array values, in which case the subscripts specify a substring to be extracted. For example, if FOO is set to foobar, then echo $FOO[2,5] prints ooba.
If a subscript is used on the left side of an assignment the selected range is replaced by the expression on the right side.
If the opening bracket or the comma is directly followed by an opening parentheses the string up to the matching closing one is considered to be a list of flags. The flags currently understood are: