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 11442 invoked from network); 22 Nov 2020 01:49:42 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Nov 2020 01:49:42 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1606009783; b=xbbkcPzijM0VAtstIXbr+FeHsnL4Fr4L9SDpbpxEaDwwjNVAf722vZIcrg5x6c+40lS9qVYyUW Q4Wysc4aCigvninAzPWSGId8YLzuB/XHBs/g4fSIx8JEt/WlknYRcSKfY+8btnkqi4apcy/cLj dvnqe7HRvVqNbIeA58oNveeSVzw4Kt+QYp4hIH2iKTv+4tvX8ex3FRbeYFNhdLmOZryFATImY6 1TuRvUU9hI5/8XuYdbX29v2GRIw9T74v+ROwUygKNOeyOENclYseA702evHKR4AYyBtQcCmkh1 s4Q0MBqPa1KHXjtQjq78h0ZIKvfXLG1xXh+3Ofi9ED33IA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wm1-f45.google.com) smtp.remote-ip=209.85.128.45; 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=1606009783; bh=+du/EWpcvp07HrWoh93KDC1560SsEUU2FuIQAbukf/0=; 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=gOLqSoZriwCCZOjroGV/IFq08D3RsOEZOUNOybGrb00KIsXgpFP552YfyzMetufGJl5WTY02Vi UvOJq/+wPVOQg6YMd3TT0/Gal0BNh2KsMNiq2GUbaOuV7lzc1MyIEwHFq1tD33OdeeGX05xTpp 1G8yB38IIbVM0wHydD/QZEykKpA3ZaTYXirg6mZdMORGgtaS2VJk8FYcDI8c/ty2Igj8RIqWoL 5N6JyYGaas7qv5pPbuzmdKl+dT5PV3dONHr4xLE1BBiqIPbu3E1xWc0ZnSPhcPFA0PJJSvaFM8 IF/gKaXzii45DXvej30Xp/E9pUTaOUhfHgsbvG5xk9tEKA==; 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=2BKvDjwIWhtNwxK+x7aVMzNMfTKEHUIxgpvPbZXk4lU=; b=AH6XtFU+PlUipGcT5XmF8C27Z+ GAohCon/9+R3c1cMlVPX8xos1tfM8vnPMrYHLlg8lCyGNzW3meo6qCavwEDituLuFujygPmH44Vzn Y9WSjn6VUZat3LeHR141cBUlq3tNRJVxsARIeJWkHIG2MUIvbHZO1mrGxDCPPwB18/jVFgw3LikL5 VfHoAz+tcmDgT4Cnr46mFJZSfNz5wVvDxTpAC76ohiqSvPy7ULWhQ2DygIy8eSrilNp3GdNNLLxsa raor/PLoba6egaKhPqD4BLJFCWxhKsRUjuegQIBRTTJhPyb4c+UXk8n007YRvmA4vi32NOlPXjtgG VLatsLjA==; Received: from authenticated user by zero.zsh.org with local id 1kgeVa-0004y1-FP; Sun, 22 Nov 2020 01:49:42 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f45.google.com) smtp.remote-ip=209.85.128.45; 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-f45.google.com ([209.85.128.45]:38306) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kgeVK-0004ox-Nt; Sun, 22 Nov 2020 01:49:27 +0000 Received: by mail-wm1-f45.google.com with SMTP id 1so13988762wme.3 for ; Sat, 21 Nov 2020 17:49:26 -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=2BKvDjwIWhtNwxK+x7aVMzNMfTKEHUIxgpvPbZXk4lU=; b=cXVkIC7qtjdWQxJIQvdZgH/JXhAYqUNLXt1fRZzFafWK44Lna2l0irR0qZnasdfryM tfWX6t7Xn4773RmM8lq4fDCVWI1Yu5jhcbY7ibAnR+d217WB7an0ga+kTFAOdTFYLJsy xvur3beyb8ALzncrYroRbuQCxRpBbfqIRlo1U/fxFIwStPqQ+MISmFYBXj4nCD7YZ+wq mvhVJIg4kV4vGklzLkDrAamR0Z8h5B3kGV2rZNiFP6OT86ZBflUN2gK8nFFQ8Jon4mgg S6uRutK5UOmPtDXZZM9YOkdK9RGQpmla3ugt9ET4ShaV0NsYw1vHFp1lylq/uFqX9Buv qoNQ== 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=2BKvDjwIWhtNwxK+x7aVMzNMfTKEHUIxgpvPbZXk4lU=; b=ppB69dkv4JXUmaZEfF0dATmMYuzbA/1DwqmC79A2JbYqbT9KCquLPBSFOwD591rIOK HpO3SETXOYCPmA+BABR5AMe7fFooljM2V5CWGBf/Wp7tkUyIjqu8ic7PNnCi/JzBcKdC JdEFiYNTL7oScq2jokIA4/cwZEUeWmUGpWkSxnrEwsx6vYr2uHxq/PGerF4OSPaprExT QO6O/fRJNji6TfNyaiIyCTDUllbGoCIp8YePYikPXqIPVd1jaQB69Beh+OKtIKRnG8Wp 58Pq3uo4XF8Uz8+VBoPr4uy4b/CZV+8sh+V+4ixNvBF9m8mJmGWZf0fsz1n6HSQn1k8m J6rQ== X-Gm-Message-State: AOAM530Px6hT9HFar/u3KCQrZcZ4Ink6EiwlD55g7EGHcFp7KaAvl0FO dNO3FdgRUPT98K0mxn9EJfPPGbpOw2+42BXk3c0= X-Google-Smtp-Source: ABdhPJzqIV59rr2KIaPoZ9gAbhHb2PksJed2LSwc26pP8eYv0kDzxHFfbLiZRgrASy85Ey1toEAmjc/PFY6/iAz2o0A= X-Received: by 2002:a1c:f619:: with SMTP id w25mr16943170wmc.55.1606009766422; Sat, 21 Nov 2020 17:49:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Felipe Contreras Date: Sat, 21 Nov 2020 19:49:15 -0600 Message-ID: Subject: Re: Bug with unset variables To: Bart Schaefer Cc: Roman Perepelitsa , Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47590 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 Tue, Nov 17, 2020 at 2:54 PM Bart Schaefer wrote: > > On Mon, Nov 16, 2020 at 11:42 AM Felipe Contreras > wrote: > > Python: > > > > foo = None > > print(foo) # None > > foo = "set" > > foo = None # unset() > > print(foo) # None > > > > Shell: > > > > local foo > > echo ${foo-nil} # nil > > foo="set" > > unset foo > > echo ${foo-nil} # nil > > > > These are all functionally *exactly* the same. And that's an undeniable fact. > > Except your examples are NOT the same. Your shell example introduces > what amounts to a ternary test. In shell > > local foo > echo -n $foo > > does not output "nil" or "undefined" or "None", it outputs NOTHING. > When you throw in ${foo-nil} you're effectively writing (pseudo code) > > if the variable foo has no value > then substitute nil > else substitute the value of foo > fi So? Is it *functionally* the same or not? > There literally is no concept of "not defined" in the shell language > outside of that implicit ternary; undefined is not a first-class > value. You cannot write "if [[ $foo == undefined ]]" or any of the > similar comparisons that can be done in most if not all of the other > languages you assert are equivalent. You can use $anydamnthing in the > shell anywhere an empty string can be used, without producing a null > dereference or similar error -- unless of course you've activated > NO_UNSET, which by the way: This is a smoke screen. Notions don't change the behavior of the code above. It either is *functionally* the same, or it isn't. > > > > The most straightforward way is not necessarily the best way. > > And the perfect is often the enemy of the good. Let's stop throwing > aphorisms at each other, especially when they can't change decisions > made decades ago. My statement was not an aphorism, but even if it was; that doesn't change the fact that it's true. I was not the one that brought history into the thread. You are the one that brought the history, which by definition cannot be changed. If now you are saying there's no point in talking about something that can't be changed (the past), then fine by me. > > KSH_TYPESET does something else that not even ksh does. But another > > option might make sense. > > Which particular something are you thinking of? My understanding of that option is that it changed the behavior of this: typeset var=$(echo one word) To this: builtin typeset var=$(echo one word) In other words: typeset var=one word But that's not what ksh does, at least the version I have installed. Anyway, I see now that it's obsolete, so in theory it could be reused. Cheers. -- Felipe Contreras