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

Re: More rabbit-holes with unset variables

On Wed, Nov 25, 2020 at 7:19 AM Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
> 2020-11-24 23:02:05 -0800, Bart Schaefer:
> > I was experimenting with ksh to look deeper into adding behavior to
> > ksh_typeset in zsh, and discovered that this example:
> [...]
> Sorry I didn't read the full discussion as I just subscribed to
> the list, but I did have a look at the differences between local
> scope implementations at some point and there are many many
> variations between shells.
> I did find zsh was far from being the worst one there.

Yes, but the discussion was about inheritance and the behavior of
unset, not about what we are discussing here.

They did mention the zsh behavior, but that's that's it. I don't think
anyone contested what in my opinion is the natural behavior, which is
described initially in the description:

  The variable whose name is specified shall be created as a local
variable with name "name". It
  shall inherit its initial value, as well as the exported and
readonly flags, from the variable
  with the same name in the surrounding dynamic scope if there is one;
otherwise, the variable is
  initially unset. Then, if "=word" is provided, the value of that
local variable shall then be set
  to word.

So, the variable is initially unset, *unless* "=word" is provided.

Do you think anyone objected to that behavior?


Felipe Contreras

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