Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug with unset variables



On Thu, Nov 12, 2020 at 2:48 AM Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:

This is a long standing feature of zsh, so the default behaviour
is not going to change.  Almost certainly there was no direct
thought at the time zsh was implemented about the details
of this case, so it was probably  not a formal syntactical
decision.

If we go back far enough, to the original Bourne shell, there's no such thing as local variables, no variable type except string, and no variable that can both exist and be unset.  Everything is either in the exported global environment as a string, or it doesn't exist at all.

The next step is variables that can exist in the global environment but are not exported.  But they still always have to either be a (possibly empty) string, or not exist at all.

Zsh preserves that behavior, then adds that you can explicitly unset a variable and zsh will remember its "type" as long as the variable is in the same scope.


Messages sorted by: Reverse Date, Date, Thread, Author