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 4966 invoked from network); 23 Nov 2020 23:40:06 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Nov 2020 23:40:06 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1606174806; b=V/wufnQA5j38gaT0+uObrQ8pZnHVJLubaNkfuEUcJYjkTSpVBY4OleSwJ1jHJrfS5Xcs5/Y5im jVBqs5prrCNXGVxltZ1LGX5JwN0tBHeWQhYDEHOUoX01vLb0hTuHhI2kj6JlC1+5lfbsrR1GSw WH1tKg/9KV3w+Qf8ayljpFWaY9IIITI+d1lH8WwmctjRCAewyKmiV6IT/rlZokojuz4gQ7NL3h MUfUZDSNjNEv7V+hRBEpi4l3DUFrCqF8J9zyfOb8bpDxVqyv80XyZ0JDOiIvkEOrxv2KLL2XIf rDKpPDwK2aRhKEBnJESHm9v2oeSJ6w4EmaCb5qhjVKQPvA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wr1-f45.google.com) smtp.remote-ip=209.85.221.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=1606174806; bh=0u58CvRIFPztrTIkPZ0bn0QoTvkXGjeax0WnXHqPuQU=; 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=kETEjYCGER03rkhV1X3R9Fj0TmADH/gVxfJo1MSPiBAKP34jm+3oSSwYBvzYuLyMBNCJDrNd4+ Anr17bSx9bo1ir/geNb6xrlPnTmzoNyJvblCIKGA8/qzohbg15Ookg/3XhGeTba2srjAw3uKC0 MrZ4wpHF4SOI1QEK2pruzYWJwVWbhBKZkuiMIUxOkN15IKoARgPjP9pRu0JooEi0H3wsSjnWAm x7Y0OUsFgUWnZru3PpmiVj1D+kqmySi3KhVCVOoQPNNYLvDGuaZzkvwuENYHR/IXgdh9tfxls9 im1gAuiCKCvIH/CdNZKkwtHSv3LF8/aFPF2UIkYHUC5ajw==; 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=K55ehMbAWsAR+xBmKV5xLRrPIq72L3Rww+dukQ7cWcY=; b=qugJsGFSKpwwu1Th54pYpgfDju oXsZn2h3sZhOQvprO3NT71Pr34M+TU7r6cCoYiFyappKTbahHKX7P3eps/KaCoCyyw9YZpKchbq8A sbtkAu5RDfQL9m1qiTcsD+onfTbStACGf2Y4cQ01S6+nOr8huhD6EHJ2x+zkpoYPwP0zlOndDDLey hQJHA4cJXlyZFXrftFBlrF7oC5tj4d6KUUG6ec01WbT8Rdlt4v9mO4nv7OL3URFfwYBWrrYGLyE85 aE437SCqyKjgoCtLy4BqdDg5QR+2dDTThgWaEKF90DO+5dXovyTqC/M/Z2RkzVOL7O7nVv6eS03CJ V/iZCKDQ==; Received: from authenticated user by zero.zsh.org with local id 1khLRE-00041e-BB; Mon, 23 Nov 2020 23:40:04 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wr1-f45.google.com) smtp.remote-ip=209.85.221.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-wr1-f45.google.com ([209.85.221.45]:35533) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1khLQy-0003rb-7b; Mon, 23 Nov 2020 23:39:48 +0000 Received: by mail-wr1-f45.google.com with SMTP id r3so2207392wrt.2 for ; Mon, 23 Nov 2020 15:39: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=K55ehMbAWsAR+xBmKV5xLRrPIq72L3Rww+dukQ7cWcY=; b=X7nGBixWwL7J7l7eRLKCRW9NrA5JoHsBWtqql3GlWID1mqdG9UV4samH4rUy0NBAod 0mz06N1oKnNQZfAlAuqyXkzYZ2jnimQ3PHM79D37/CQp8PWJ8zDqsLFFxgowSdAxs51f sQ1tljHAhbhAjpndkUqVIGYUZxB3sQt89J8jx/AzjdZhzq/N+KNY+us3czjrPQjveIyc YYdEjDYhPBx/RfOjpL2pbkjf9NwjpxISwxQNFkUeR60PSp04rbKuMaKe0aNiXAMaL6vu W278TAyYSEklWEASI5O5gOh59QaGzD+ssYBqvKxxDli/a1/Z00mXPM2jPCRU62Q+LcHv 0fFQ== 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=K55ehMbAWsAR+xBmKV5xLRrPIq72L3Rww+dukQ7cWcY=; b=Dl9Db75A/2SUVlSlneM66CxvsOK+FUbBVsTqInE+/Km2CTaDrE8QpHwywZG6Lf4LBw aQFMAXOPNokGeu0YKJ/lU9aei7gwMxmPQ3QeoBIysQi63kSv5FC2j4lpvA4HQSk7OoWu /jgEGn+CbeMS39wzQK10UizI6Y8m+CkEHMq/GZtgdEt2RIIH5gerswyHoS8AuX/NbcIU fg4sfd7lg0YG4jfFFBurMNZ1r2OAcOTZa2LTnXnvC5BDRtIiCyQHdtrBHk630v6qNtsm Fl562nThDcoMS0l3fWmraUihaTRYkVPp1LPwFRH/QXSENOMM7CgVb7sKdC+mSKE/BZNR UlBg== X-Gm-Message-State: AOAM5303ur/wjEYcycoECmAlLJSQfFEIKNZ7QWIWNOAVpW+DqK8FJrnc elDFm5p4CNXoSfe1jEDtkHkvGippFnBynwhNVFYth2Bie9kJhw== X-Google-Smtp-Source: ABdhPJw0LUW0iGcO7O/0vQtiyx+7FFR8jXl6z/vz7LV65jbEvymIkvGeiibi1RemPdMG3kKQlgKYVWENrx4wv4ZVrSw= X-Received: by 2002:a5d:67c2:: with SMTP id n2mr2075398wrw.139.1606174787231; Mon, 23 Nov 2020 15:39:47 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Felipe Contreras Date: Mon, 23 Nov 2020 17:39:35 -0600 Message-ID: Subject: Re: Bug with unset variables To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47611 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 Mon, Nov 23, 2020 at 2:26 PM Bart Schaefer wrote: > > On Sun, Nov 22, 2020 at 11:27 PM Felipe Contreras > wrote: > > > > Nope. I demonstrated how they are functionally the same with plenty of examples. > > All of your examples are from other languages. "It" in this case is code from Python compared with code from shell which is functionally the same, that is to say: it does the same thing. Of course it's from other languages. That's precisely what is being compared. > > But then you used an historic argument to counter my claim that Zsh > > was not consistent. > > The historic reference was for context. The actual argument is that > zsh is consistent because the behavior of variables inside function > scope mirrors that of variables at global scope. History is merely > why variables behave that way at global scope. You used history to explain what was the most straightforward way to implement the new feature without much architectural changes in zsh. This does not imply it was the best way to do it, nor does it show it is consistent from the user's point of view, because it's 100% dependent on the implementation of the shell. > Your argument is that zsh was wrong to adopt that interpretation of > variables in function scope. That doesn't make it (internally) > inconsistent, it just makes it different. I did not argue it was internally inconsistent. I grant you--after looking at the code--the change was likely internally consistent. My argument is about the consistency from user's perspective. This is the example I gave to Roman, which went completely unresponded: func () { [[ -n "$1" ]] && var=$1 dosomething ${var-other} } func () { typeset var [[ -n "$1" ]] && var=$1 dosomething ${var-other} } > > I argued it makes sense to add a setopt option that turns on the > > behavior that a) in my opinion is more consistent, b) is what Bash and > > ksh does, and c) is the equivalent of what virtually all languages do. > > That's where we could have been ten days ago, but you said (of > changing the default) ... > > "Nothing is impossible. It's just harder when you don't even think of > trying it." Yes, that was in response to you saying it was infeasible to change the default. I argued that nothing is impossible. It may be infeasible in the final analysis, but maybe not, the only way we could know is if it's tried first (with an option). So it's perfectly consistent to argue both: a) a setopt option makes sense now, and b) eventually this option can be considered to be the default and it's not necessarily completely infeasible. > ... so we've been down the rabbit hole of arguing necessary/desirable. > > To hopefully tie this off, does anyone want to argue for a new option > instead of adding this to KSH_TYPESET? Not me. I'd say any way to enable this mode would be fine, and if there's no conflict with KSH_TYPESET, that sounds like a sensible option. Cheers. -- Felipe Contreras