Zsh Mailing List Archive
Messages sorted by:
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=18.104.22.168; 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:firstname.lastname@example.org?subject=help>
- List-id: <zsh-workers.zsh.org>
- List-owner: <mailto:email@example.com>
- List-post: <mailto:firstname.lastname@example.org>
- List-subscribe: <mailto:email@example.com?subject=subscribe%20zsh-workers>
- List-unsubscribe: <mailto:firstname.lastname@example.org?subject=unsubscribe%20zsh-workers>
- References: <CAH+w=7Zag5MG5D=cRS2UMSsqJ0t=iw5MH9j8=HBO1Q77nbs03w@mail.gmail.com> <email@example.com> <CAMP44s0-ki=TBzTwnqx10FcTLX4mbphwN88UCx0+h97JTecBWA@mail.gmail.com>
- Sender: zsh-workers-request@xxxxxxx
On Wed, Nov 25, 2020 at 2:17 PM Felipe Contreras
> [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
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
I'll note that posix defines null as "" (double-quoted empty string)
although it requires a careful reading to find that.
Messages sorted by: