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=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14981 invoked from network); 12 Nov 2020 19:50:10 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Nov 2020 19:50:10 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1605210610; b=qemut3wuZMTX7CKAs0zN7dJgt0jFjXujQRv0VFxDDkGR5dr6EHd481W4crwWokeFmi2eIh/Uxf 6xzz6G43rw4an9u2QDKKSyE5lNDLn4ZTtL9e1qC6Cg6wp/ZI1kQYDmHcjgJAaQRZq/Rn1uLQwU j9jqGo0Sdw9mOFGpshBpXlOlRFKFo3va5HQWvdBuhLrcQoGMlA6x52W7sppxX7EZuEpEzqHa/g ZJ0KmAhhN3I7lg8+UrdibTRGUzjgk03RFHjtiG0yQVGYomP03W+ZDAH+/yF1ZvjzWBtGgs7Kd9 0zuAPdwzrBJJ9v1/w0OFehRkHNcpUvzDEQmhcGSd6HOVMQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wm1-f41.google.com) smtp.remote-ip=209.85.128.41; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1605210610; bh=3MkMs+2jbPBssHMccv/5X3byEdVNT0bWJbjVxCaukF8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=px6U6fCBE3eVzMcynytOr6jszmKMvHqgUKeVCAQWyhfUqqMF3GwhLBXGnK81C6j099jryPkIuh WRFX+r0sqm02q4d6ItqBvlWR8vDiy+bJKVQRm1KQXK79Z2SarG8eANavpoY7jusvqAuBqF/1Rq q7M4oF5XKkoCSHJios5NsbTq2Cw/ODLmfyN4MTNwXI+Pe5NBqM3y4DdtFlb9FEw+w9+hWl4waB hyr34fV2T5Cmzg0VAGXCqKRlB5dOGXKlVTOsDKkSdtSDfS5Ikt/8jSOe2TOp5QgzLfTLHYpihh o2YHcCAjjKnMw48An0ioztVOAAqBSzciVLvf8WtJ61lUiw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=rL1+aucyfwMIedaLTM5HMH1t9nIQNNMxFmNnuHNMdY4=; b=ONJlPWeNaxgX5Q/H9LEDCt7AOW AS94LEUfU6mv5tliWmeUtTHLqLeIGaJAYVj5ArGJrgr4hF0M/TRydgJnsmgfAGXZHlSkBBbLi2LBr zmQQfOs9YHI/vvppDsIuiCHFApBkWmGoKfW0Sr+mOeoV7PCVXG8+tXBMo9gagg28Fs/uFLa0bDOY9 LgE/73A4pt5y1ojs8He3zm032YTavBEE0Tzw4p0dR4dWWRvc61hm2b1oSSTdlhnjNljAFQFD5kmM6 k39rBYjncAz/JGAVlK0ZI5pCS7qQd+Nq+21nDvvD3SexGefkmnMJy1LjkMHt8h3HpjODFhRZIFPuI LFMOyxRw==; Received: from authenticated user by zero.zsh.org with local id 1kdIbh-0001oH-BS; Thu, 12 Nov 2020 19:50:09 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f41.google.com) smtp.remote-ip=209.85.128.41; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wm1-f41.google.com ([209.85.128.41]:38077) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kdIbM-0001eH-IF; Thu, 12 Nov 2020 19:49:49 +0000 Received: by mail-wm1-f41.google.com with SMTP id h62so6540265wme.3 for ; Thu, 12 Nov 2020 11:49:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rL1+aucyfwMIedaLTM5HMH1t9nIQNNMxFmNnuHNMdY4=; b=Zhsq+Xhl1Y+EUeQRlpPRvV4uYb5CZWXgdEFYkkjFeLKD4GfbJpOuO5FhWBrADPCu/I /mo1iWO46KA+nHL5QX0chgcLIJzbFc/ho8prCLAO+6KZiqSS6TPiDHtt2+MEjD46XXHy xRRf57zTLBfRKKxa7cF3SgHOS/DBnH9ruteh39mYqQ/jCZJDQwfRLPtek0A5jlAcSdcw 00CU65zH2R/BDz4aUvPuBxf4wz/f1KabSa7TLBb8sivMJ1fZO27yiozVBfNULIoVL8Jt x1kanURP9fk0FqpnnsNljj8clLPe+f6rq4lNwrXn8I3dJWxesRkCEpNKOdIye2uOpFzI P+VA== 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:cc; bh=rL1+aucyfwMIedaLTM5HMH1t9nIQNNMxFmNnuHNMdY4=; b=J6fHa7rbLBb7M5QDMKtV1gA7w23YWJch+Api44ua/0wvqCHJCNTPW1bfcYYM66J90c JbdA/2HO8E8yWwkI/JiBOfKqn//S+qwbd9M+XqGqC9Z7E+w7+gUq+VVz6w5ayvNpsru/ 5G0EeUT8p17n8gcMyz+5X73iQ/Y2IDaeicdIcFA4DpvEXasQ+/65kB0RGr6BbOkdJWox D+7Ma3ztHrTRssXQ/2z45pDL4D0KyfyL7tLtR07kSJzgBwj9i5C7/fFXj8sqbKoCN+sR NSbiQHY2QfUc6PpY8AqbahNQ4z4eZwVwz5zzGpBMBuO75Jtg9CJDuC1CYYf9qULQ5VMW uJNA== X-Gm-Message-State: AOAM532d4O60W4CTGkZFoC/la9f0kZpyVV7B8jkZqQv7lrCJCIIiYCud SfzFQcPthlBgXN4D+tewf58wp1usP4rCMSbdk4E= X-Google-Smtp-Source: ABdhPJyc0tvL7uD9WRDkbYBan5pgTX8deBbBiD88JvMUvSOq9zJrm8niL5scLrrIzFS8n5vukyiQTLFa0uO5wcFkZaU= X-Received: by 2002:a1c:4054:: with SMTP id n81mr1297258wma.48.1605210588014; Thu, 12 Nov 2020 11:49:48 -0800 (PST) MIME-Version: 1.0 References: <887944058.1348251.1605178076357@mail2.virginmedia.com> In-Reply-To: <887944058.1348251.1605178076357@mail2.virginmedia.com> From: Felipe Contreras Date: Thu, 12 Nov 2020 13:49:36 -0600 Message-ID: Subject: Re: Bug with unset variables To: Peter Stephenson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47552 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 Thu, Nov 12, 2020 at 4:48 AM Peter Stephenson wrote: > > With some trepidation, let me see if I can try and sum up. > > fn() { > typeset foo > # foo is regarded as set (in the sense "not unset") here. > } > > Other shells would treat foo as unset at that point. > > This is a long standing feature of zsh It's not a bug, it's a feature! Never heard that one before. > It is a bug when emulating other shells (although note that there > are plenty of such bugs --- emulation is never complete). I > said I thought we'd done something about this, but I don't see any > evidence, so I was probably wrong. There is definitely scope for > improvement. Indeed, I've been looking at the code, and there doesn't seem to be anything similar. It's making too many assumptions about the starting state of a parameter. > Given that all shells would treat $foo as an empty string in > the context above, the practical impact is limited to a few > edge cases --- granted that can be infuriating (and more) > when you hit one, so I am not dismissing such cases. That's why > this issue doesn't often come up despite its long-standing > nature. Absence of evidence is not evidence of absence. Perhaps a considerable amount of people have hit this issue, but they haven't bothered to contact the mailing lists. Most people just make it work on their code, and move on. > For the same reason, that $foo will reliably substitute as > an empty string, I don't see any *overriding* reason for > the behaviour of other shells. That absolutely doesn't > mean I see no arguments for that behaviour, all of > which I think have now been rehearsed. There is a difference between a variable that contains an empty string, and an unset variable, this is an undeniable fact about the shell language. There is a reason why people use ${foo+set} instead of $foo when they want to check if a variable is set, as opposed to empty. The fact that most code doesn't care about the difference doesn't mean there isn't some code that does. Cheers. -- Felipe Contreras