Parameters in the Korn shell
Korn shell parameters are discussed below.
A parameter is defined as the following:
- Identifier of any of the characters asterisk (
*
), at sign (@
), pound sign (#
), question mark (?
), hyphen (-
), dollar sign ($
), and exclamation point (!
). These are called special parameters. - Argument denoted by a number (positional parameter )
- Parameter denoted by an identifier, with a value and zero or more attributes (named parameter/variables ).
The typeset special built-in command assigns values and attributes to named parameters. The attributes supported by the Korn shell are described with the typeset special built-in command. Exported parameters pass values and attributes to the environment.
Name=Value [ Name=Value ] ...
If the -i integer attribute is set for the Name parameter, then the Value parameter is subject to arithmetic evaluation.
The shell supports a one-dimensional array facility.
An element of an array parameter is referenced by a subscript. A subscript
is denoted by an arithmetic expression enclosed by brackets [ ]
.
To assign values to an array, use set -A
Name Value ...
. The value of all subscripts must be in the range of 0 through 511. Arrays
need not be declared. Any reference to a named parameter with a valid subscript
is legal and an array will be created, if necessary. Referencing an array
without a subscript is equivalent to referencing the element 0.
Positional parameters are assigned values with the set special
command. The $0 parameter is set from argument 0
when
the shell is invoked. The $
character is used to introduce
parameters that can be substituted.