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

Re: Bug with unset variables



On Thu, Nov 12, 2020 at 10:47 AM Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
>
> No. Zsh is not consistent. I did not type /typeset var=''/, I typed
> /typeset var/.

At the global level you cannot write

VAR

to create a variable named "VAR".

VAR=

both creates a variable and assigns it empty string.

So now we have to decide what to do when with local variables.  They
can either have a totally new semantic, or we can follow the semantic
for globals.  Guess which one makes more sense when you are adding
local scope to a language which previously had only two possible
conceptions of variables (exist and are empty, or do not exist at
all).

That said ...

> Adding a setopt option for the new behavior doesn't break a lot of
> existing zsh code.

It probably wouldn't break any _scripts_ even to modify the behavior
of KSH_TYPESET for this.  Whether we can cleanly perform an implicit
unset in the C code structure, and (if not) whether cobbling this in
is worthwhile, I haven't investigated or formed an opinion.




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