From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,RDNS_NONE, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.4 Received: from authenticated user by zero.zsh.org with local id 1kiO5g-0007Af-MI; Thu, 26 Nov 2020 20:42:08 +0000 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 Received: from mail-oi1-f174.google.com ([209.85.167.174]:43522) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kiO5I-0006wP-EG; Thu, 26 Nov 2020 20:41:46 +0000 Received: by mail-oi1-f174.google.com with SMTP id t143so3486929oif.10 for ; Thu, 26 Nov 2020 12:41:44 -0800 (PST) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=kaSXd7cN+2uxfpiHcL1l4tm6J/PMjDrdMxEJyylMRQQ=; b=jTc74wA6fANLiItCKcPVvpNUwcn0aVTHD8HJLsjvpFfuYJhlJXiAJnGR6KG/OfYBUo 6ssdI/vah4lfBusUQ4mj2U1CpzADm9ag/hhYiRVR0qvNNu1R6N0N0xeIwUgD0gAaXnPV mwjlTclCFCPEt5DXaazBbZz9BXVwAN8KKPeaai5xNWpgsPOJL6p12C+0xYw8CyYnsfRJ s7UnIeDlKE5GhP9gNDHy2YpXdW6oX9D+xo3lTMwCksjH0aHULPwkEFEKM/YAOYQTTQht nuRam2Y8YqgMUeq3Tg0AkwefhO8DqY1U1dyaUr4mHFxglB3azYME93HlE75E++NOrC+t bT1w== X-Gm-Message-State: AOAM530KcFVuQaEd83pyPAe9Cm/rOatuzmVgjJtbRS/bVQQb+TfdVGUh oqg8TSOCXTzn/dbccQ++gNy5GIH6zQNqntWQ3MeT01ks+ZVQ1g== X-Google-Smtp-Source: ABdhPJxgOR3iMq6ZfRsX4mmxicPe5cNTVtxkSnVS/OVR3OErJBeJgves7y2VhYgG28xWLsdTmjApWbRiH/4upuuKkOo= X-Received: by 2002:aca:bd45:: with SMTP id n66mr3196938oif.132.1606423302556; Thu, 26 Nov 2020 12:41:42 -0800 (PST) MIME-Version: 1.0 References: <20201125131921.vay7h3xk5qn4odgg@chazelas.org> In-Reply-To: From: Bart Schaefer Date: Thu, 26 Nov 2020 12:41:31 -0800 Message-ID: Subject: Re: More rabbit-holes with unset variables To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47643 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: On Wed, Nov 25, 2020 at 2:17 PM Felipe Contreras 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.