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=-1.0 required=5.0 tests=MAILING_LIST_MULTI, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: from authenticated user by zero.zsh.org with local id 1kiFLi-000I3V-PF; Thu, 26 Nov 2020 11:22:06 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1kiFLR-000Hof-76; Thu, 26 Nov 2020 11:21:49 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.93.0.4) (envelope-from ) id 1kiFLO-000MR2-GE; Thu, 26 Nov 2020 12:21:47 +0100 cc: Zsh hackers list In-reply-to: From: Oliver Kiddle References: <20201125131921.vay7h3xk5qn4odgg@chazelas.org> <20201126061029.in5tpnrg5bplam5k@chazelas.org> To: Felipe Contreras Subject: Re: More rabbit-holes with unset variables MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <86242.1606389706.1@hydra> Date: Thu, 26 Nov 2020 12:21:46 +0100 Message-ID: <86243-1606389706.499549@-gQx.nNYG.4Z3k> X-Seq: 47635 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: The original Bourne shell did I believe have both export and the ${...-...} form. Using /bin/sh from Solaris (available for Linux as heirloom sh): export FOO echo ${FOO-replacement} Will output the replacement. It appears that export VAR will not export an empty VAR even in zsh (unless you do VAR=""). So zsh's not exactly consistent. typeset [-x] is arguably just a variant of export. This does change how I regard zsh's behaviour. It isn't zsh taking a different but equally valid approach on an extension but an sh incompatibility. It once was a bug even if now too entrenched. Zsh's behaviour is long-standing - I've even checked 2.5.03. And it is well-defined behaviour so declaring it a feature is an option. It does make the KSH_TYPESET option somewhat less appropriate because this effect also applies to sh emulation. But if we decide to "fix" it for zsh, I don't think it'll break too much. Given that empty values are rarely especially useful, I've always used the :- form. If the change sits in git for a reasonable time, we might find out how much it might break. I did reply on the initial thread but the References: header hit a mail server limit for line length and it failed. So I've covered my main point but just to pick out something from this thread: Felipe Contreras wrote: > The discussion is about what "typeset var" (with no type) should do. That is not "with no type", it has the default type which effectively is a string. Other shells also treat such variables as an empty string for the purposes of other features. Try += for example. Oliver