Add an optional mode to env_get_string()

The mode restricts the scope in which the variable is searched for.

Use this new restricted scope functionality in the `set` builtin. This
fixes `set -g` to not show local shadowing variable values, and also
allows for scoped erasing of slices.
This commit is contained in:
Kevin Ballard
2014-07-12 14:40:46 -07:00
parent 2457997cd9
commit dcc043df3b
4 changed files with 97 additions and 79 deletions

View File

@@ -65,11 +65,7 @@ to the scoping rules for variables:
In query mode, the scope to be examined can be specified.
In erase mode, if variable indices are specified, only the specified
slices of the array variable will be erased. When erasing an entire
variable (i.e. no slicing), the scope of the variable to be erased can
be specified. That way, a global variable can be erased even if a
local variable with the same name exists. Scope can not be specified
when erasing a slice of an array. The innermost scope is always used.
slices of the array variable will be erased.
\c set requires all options to come before any
other arguments. For example, <code>set flags -l</code> will have