22.214.171.124 Variable Substitution
Variable substitution happens when a `$' prefixed word is found
in a command. There are three types of variable substitution:
- where name is a scalar variable. name is simply substituted
in the word for its value. name can contain only letters,
digits, or underscores.
- where name is the name of an array variable and index is the
index into it. This is substituted by the value of the array element.
name must contain only letters, digits, or underscores.
index has variable, command, and backslash substitution performed
on it too.
- where name can have any characters in it except closing curly
bracket. This is more or less the same as
substitution except it is used to get around the restrictions in the
characters that can form name.
An example of variable substitution is:
set a 1
set b $a
which sets the value of variable
1, and then sets the value
b to the value of variable