Hi Dan,

On Thu, 16 Mar 2017 14:30:06 -0500, Dan Douglas wrote:
> On 03/14/2017 05:08 AM, Jean Delvare wrote:
> > So internally bash does make a difference between a variable being
> > null and a variable being unset. A bash variable can actually have 4
> > distinct states: non-existent, existent but unset, set but null, and
> > non-null. "typeset", "local" and "unset" all put the variable into
> > state "existent but unset" (unlike mksh.)
> 
> It depends on context and the type of variable involved. Arrays complicate
> things and namerefs _really_ complicate things. In bash, declaring a
> simple local scalar, assigning it a value, then unsettling it within
> the same scope brings the variable back to the same "hidden local"
> state it is in when declared local but not given a value. However,
> unsetting the local from a child scope does fully destroy the local,
> uncovering the variables in parent scopes.

For the least educated of us, of which I am, can you explain what you
mean by "child scope"?

> Thus bash's is actually the most flexible of the dynamic scope systems
> in some ways. If you want bash to behave like mksh just define a wrapper
> function for unset (I usually name it `unset2'). Contrast with zsh,

What I needed was the opposite, and Thorsten helped me achieve that.

> which has no way to unset a local (last I checked, which was years
> ago). In addition, bash has `declare -g' for directly acting on the
> global scope. It has a few good uses e.g. for setting special variables
> like PATH or LC_*.

Thanks,
-- 
Jean Delvare
SUSE L3 Support

Reply via email to