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

Re: The emulation rabbit-hole RE typeset/unset

On Sat, Nov 28, 2020 at 3:36 AM Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
> An integer is not a "simple scalar", and seems to be useful unset.
> Or am I missing something?

Two things.  Possibly three.

One, 'the only useful "declared but not set" variable is a simple
scalar' was a statement on the ambiguity of the austin-group proposal
that you excerpted, which explicitly made "declared but not set"
equivalent to "unset".

Two, that neither bash nor ksh actually does make those two things
equivalent.  Variables in bash and ksh can either have both properties
and values, or only properties, or neither.  Variables in zsh
currently have only the two states of both or neither, because the
latter is the definition of being unset.

This is what we've been saying all along -- zsh currently has no
provision for representing "only properties", and consequently the
only way to get any of the behavior of the properties settable by
typeset options is to provide a default value.  The only thing zsh can
currently represent independent of some value is function scope.

Three, maybe, is that math expression context has a special definition
of the meaning of an undeclared name, which is not the same as the
definition in the rest of the shell.  It's not a parameter expansion
in the normal sense.

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