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

Re: BUG: Initializations of named references with an empty string should trigger an error



2025-05-26 10:30:19 +0200, Philippe Altherr:
> >
> > typeset already uses -R for something else.
> 
> 
> Right, I missed that one and -r is already used for readonly. My first
> choice would have been -u or -U for *U*nset but both are already used.
> Another idea was -f or -F for *F*orced set but again both are already used.
> So maybe -S for un*S*et or forced *S*et.
[...]

See also https://www.austingroupbugs.net/view.php?id=767#c3739
and below.

That was about an effort to standardize "local" for POSIX sh.

There are variations in behaviour with local var in that
depending on the shell, the variable is either
1. declared initially unset (like in zsh when in sh emulation)
2. inherits type, attribute and value (like in the Almquist
shell which AFAIK was the first to introduce a "local" builtin).

(though some shells doing 1 inherit *some* attributes such as
export).

A proposal to reconciliate the 2 categories was to add some
options to pick one behaviour or the other.

-N for null/not-set, and -I for inherit were suggested and were
implemented by NetBSD sh.

bash added localvar_inherit and localvar_unset options instead.

That effort was abandonned as it was not possible to get
agreement (that issue was far from being the only one).

So if a new option must be added for zsh's "typeset"/"local" to
mean "make it initially unset" (as is the default in sh
emulation), I'd suggest to use -N to align with NetBSD sh, and
that will make it a more powerful precedent if POSIX want to
revisit specifying "local".

-- 
Stephane




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