Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: More rabbit-holes with unset variables
- X-seq: zsh-workers 47643
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: More rabbit-holes with unset variables
- Date: Thu, 26 Nov 2020 12:41:31 -0800
- Archived-at: <https://zsh.org/workers/47643>
- Archived-at: <http://www.zsh.org/sympa/arcsearch_id/zsh-workers/2020-11/CAH%2Bw%3D7bs9E7whJLugMLOXG05R-2S8Hjt%2BOOKK_KN%2BSMxv-Vvaw%40mail.gmail.com>
- Authentication-results: zsh.org; iprev=pass (mail-oi1-f174.google.com) smtp.remote-ip=209.85.167.174; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=kaSXd7cN+2uxfpiHcL1l4tm6J/PMjDrdMxEJyylMRQQ=; b=y+l+B/HXJV73OgOVC67S7YpeO6M3O2cJzfKjI6kGwxN8VsSLjo53yLG6urQNGczAEp YM+XMXg9fBhLPGFypE/c4GlfZRh2yFZ3ka2ptZzSXLr2e77aj/6p9Q38ztWn0e+FEU2m cZHXvJ60OM7GntxQsWfMNK8Eyz0oAcwLQ/wMHVLajcJyQ4QjeNRBIhz9KtSMmu4pmg7Q Ea5/1LMh6yMj1eJFElyS8QEdP1ZO+rbGqIIgOpn0BEeTaOQ8Q4TihlpMt7av6DwM+wWN tNKwvfcu47cVui3m1A8KD+mpCWg9tjyBrOp79Cn0ziE77nMqq9F6RFbnwmWXUFH+5HYw EIJA==
- In-reply-to: <CAMP44s0-ki=TBzTwnqx10FcTLX4mbphwN88UCx0+h97JTecBWA@mail.gmail.com>
- List-archive: <http://www.zsh.org/sympa/arc/zsh-workers>
- List-help: <mailto:sympa@zsh.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:zsh-workers-request@zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-subscribe: <mailto:sympa@zsh.org?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:sympa@zsh.org?subject=unsubscribe%20zsh-workers>
- References: <CAH+w=7Zag5MG5D=cRS2UMSsqJ0t=iw5MH9j8=HBO1Q77nbs03w@mail.gmail.com> <20201125131921.vay7h3xk5qn4odgg@chazelas.org> <CAMP44s0-ki=TBzTwnqx10FcTLX4mbphwN88UCx0+h97JTecBWA@mail.gmail.com>
- Sender: zsh-workers-request@xxxxxxx
On Wed, Nov 25, 2020 at 2:17 PM Felipe Contreras
<felipe.contreras@xxxxxxxxx> wrote:
>
> [quoting an article from the posix tracker]
> 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?
Is there a newer version of the standard than V4 from 2018, which is
the latest I can find online?
"Local variables within a function were considered and included in
another early proposal (controlled by the special built-in local), but
were removed because they do not fit the simple model developed for
functions and because there was some opposition to adding yet another
new special built-in that was not part of historical practice.
Implementations should reserve the identifier local (as well as
typeset, as used in the KornShell) in case this local variable
mechanism is adopted in a future version of this standard."
So the language you're quoting was rejected, though not for that
specific reason.
In fact, unless the notion of typed variables (integer, array, etc.)
is excluded, that language is ambiguous, because (as I've mentioned
elsewhere) the behavior of an "unset" variable in other contexts (such
as assignment) is that it takes on the attributes from the assignment;
so a the only useful "declared but not set" variable is a simple
scalar.
I'll note that posix defines null as "" (double-quoted empty string)
although it requires a careful reading to find that.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author