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

Re: One possible answer to typeset vs. unset



On Sat, Nov 28, 2020 at 11:49 AM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> A typeset variable with no assignment triggers NO_UNSET warnings when
> the name is used in parameter expansion or math.

There are a couple of possible ways to amend this.

The most radical would be for "typeset foo" to fail when NO_UNSET,
thus forcing all declarations to assign explicit defaults.

The other way would be to test the PM_DECLARED flag and treat the
variable as if set.  This could cause problems for (at least) numeric
types, because $num returns empty string rather than zero, which is
exactly the sort of thing you want NO_UNSET to alert you about.

So the right thing is most likely no amendment at all.




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