local [ name [ =value ] ... ]
Description
You can use local to make a variable local to a function. When a variable is made local, it inherits the initial value and exported and read-only attributes from the variable with the same name in the surrounding scope, if there is one. Otherwise, the variable is initially unset.
qsh uses dynamic scoping, so that if you make the variable alpha local to function foo, which then calls function bar, references to the variable alpha made inside bar will refer to the variable declared inside foo, not to the global variable named alpha.
The special parameter - is the only special parameter that can be made local . By making - local, any shell options that are changed with set inside the function are restored to their original values when the function returns.
Options
None.
Operands
Each name specifies a variable in the current environment. If a value is also specified, the value of the variable is updated.
Exit Status
Related information