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 28415 invoked from network); 12 Nov 2020 21:49:09 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Nov 2020 21:49:09 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1605217749; b=sC6z0esWG+6yY8dsJs4m9+yE75a9/S6kBYcKPRYEA6wjqJ3ytgAj58sIAn3yOC5BCq5DaUBxjA tC4W7xfBc1QWmOfoVA2cbDMhsqrth3B1lyKoaPNyDY/JDzAGc2HjyignVv8NnTlm34YX1L6Kao HOGchkEbn+gFAbPLqz9eML4U8zR7HWiYK0+NrhJFCJb3Is3uyMvikIBoe/EGtC8MGJzvI1bxRq U06Vpn9jKTC9+uKL+2X4kXtliipo4etp5Bz49JgSzBm4VdiEpF11JfaIW9R1b5eQq5oY/DGf4N KS1yGtj2qKl/a0CJk/SEjH9lcXTF53vzl/ubB7FKcec35A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wr1-f50.google.com) smtp.remote-ip=209.85.221.50; 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=1605217749; bh=1BVxr4FndfSaaqz3bhId4OLUr+P+GOisCM9Yx6PW67I=; 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=XwmxeLtMMfaPu5AiJmq7E79S2vx25AwglMl3cp7yPEdcqvZxic24Tb/Ecltc4R8+hxRqJmGvhj Mt2EKxjSSK42mU2wqIi0A35StAWHP7ntcxPsWSljLWc2mNB6//NH2z/ApjHw+xyue4mx1+ODNB c5lCvLM/ZvjN7UzzPedOIegCj2bPVrqbV9XXI7qQAtYl9B5d2XgBJxd+ikU7FfmvmYhyjsGB4y 1xA7io75+OYmJ20Tj0hBHM3gA0wmCg1ITcJqhBDGpkG/GgTzEJdv63sy0PoNiiVN/O1h3tRT4V hZ8mJZjATiL/Tnm/TZNBulVHgs41feO0oDMhZ+5FB40b6A==; 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=XFrAY4RK9szWWvw6Q6xJobjXs/DM/VRdu8I72JXdiL8=; b=RrBblYczgSdZK38FIGCXagiKmQ 4ptyqDRbdp/MuKeCJCjpywVxjZnR3Tm6tfnbnUCib8tvW6ily0gV0Fex8rDx6QogaBnSZV7J4/i48 3D4bQS4oAj220BZpWJILGAN2ET/muXdyncfTALA1w4GcweU69M7eDn/QWLLarLhwOp4cXnBb3gCI5 ysn1A8h5NEvI9CZ6c7kxG3qUNbYSpG+1ZVO9Sug+0KwBwVilkxtg/sBGba8kGNaNn+svlGNTZCXvF Qmg34hjcH492eTfOY1kjNHfKxQI2bU0c0eIkvzWs8j1QVmqZaPogoz4xsA50MxpZgFFlZlMIFdsq0 Xjin4RQw==; Received: from authenticated user by zero.zsh.org with local id 1kdKSq-00053D-KS; Thu, 12 Nov 2020 21:49:08 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wr1-f50.google.com) smtp.remote-ip=209.85.221.50; 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-f50.google.com ([209.85.221.50]:41562) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kdKSa-0004tu-IP; Thu, 12 Nov 2020 21:48:53 +0000 Received: by mail-wr1-f50.google.com with SMTP id 23so7556680wrc.8 for ; Thu, 12 Nov 2020 13:48:52 -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=XFrAY4RK9szWWvw6Q6xJobjXs/DM/VRdu8I72JXdiL8=; b=S41EVJb1u6eEZ8CL7KO5F2/8uL9+ZcI8whT98lSZw6f+ZB53gsfwePX0vE8LhasKzX UTdPW2fd0iyZpEHIfHmS0gat/Xh644F+weAaUKJ8o/mb2IT5m8AahHZCOjs50Ogv58y0 N5m7ZGdt8IAzVcaErOoWN0+i55cviWg2Rj1W2z/LbfDF2JkM3NNXXyYmW4dWc+di1czj 6SDrKdCtczegGSwxjUwzpb9DQ3INV7AriTDzFJFv+gy8w/u9AI6rwhJFth3ri7yXxqo0 TzKr4ZT9RflVrQkLasnIy/zj3rCUpjk6teoj/PTmdh/OIVRGzBKz+2GbThWKTEyhkBt9 MS1Q== 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=XFrAY4RK9szWWvw6Q6xJobjXs/DM/VRdu8I72JXdiL8=; b=fXLBbvqL/GbiRttZ2MjHAPE08h7pXFxDPVndwzjjwDS7HAmBpHxcSeki2fwEMQ2asb nuPg9J8NeI27+RKN1rhix2Ux+ULbMq9Z2PZXaTptWpjW8jbT73q6fmVXy+jQrRQtNAJY IJuTToXmqSdxjScjEn37mVNcNAoWsEIP1WiUDQD8pS/JP9y96EYyJ7vhXipMKGI6hR4E oIX6CwCOwc3LNiVj3eYMiWEMSqW1mb035kqsb6/XHacSmdaVI+bJ7CPKILvNyilWTCj/ PmA4WMCYofiReaId3SHlfTB/pSjN/0A5SQwHzIEAXVW8Ri6bulckvYXUdVTp0bgg6hh4 x1JA== X-Gm-Message-State: AOAM533dWvDKW9Z0B7yOpk+Xlu8TlOtD/hnoHARzZW1WC9P1EkMDlNGy bbimhe7qTSVu5TkPvegEg/QF7dwIl21c/gGuq5U= X-Google-Smtp-Source: ABdhPJys2ey9ZHatfoGvbidA79toNDBGtYcYCY6RXRLzSiwhKXGXrh8JPheXwjzrMFfsg26Cd6eVrNDfq8sCFFVBFwY= X-Received: by 2002:adf:de91:: with SMTP id w17mr1860539wrl.84.1605217732134; Thu, 12 Nov 2020 13:48:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Felipe Contreras Date: Thu, 12 Nov 2020 15:48:41 -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: 47554 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 1:26 PM Bart Schaefer wrote: > > On Thu, Nov 12, 2020 at 10:47 AM Felipe Contreras > wrote: > > > > No. Zsh is not consistent. I did not type /typeset var=''/, I typed > > /typeset var/. > So now we have to decide what to do when with local variables. Which is probably the main purpose of typeset (i.e. local). > They > can either have a totally new semantic, or we can follow the semantic > for globals. Syntax is not semantics. var= typeset var= These two have a very similar syntax, so it makes sense that the semantics are the same. But there's no previous equivalent of "typeset var". > Guess which one makes more sense when you are adding > local scope to a language which previously had only two possible > conceptions of variables (exist and are empty, or do not exist at > all). There's a third conception; a non-empty value. var= typeset var= var="foo" typeset var="foo" These are obvious. The only thing that is left is deciding what "typeset var" does. These are the options: 1. Errors 2. Nothing 3. Changes the scope 4. Changes the scope and sets an empty value 5. Changes the scope and sets an arbitrary value Obviously 1 and 2 are not useful options. 5 doesn't really make sense, and 4 is a subset of 5. More importantly; there's already ways to do 4 and 5. So why not do a) something useful, b) something that isn't arbitrary, and c) something that can't be done in other ways? > That said ... > > > Adding a setopt option for the new behavior doesn't break a lot of > > existing zsh code. > > It probably wouldn't break any _scripts_ even to modify the behavior > of KSH_TYPESET for this. Whether we can cleanly perform an implicit > unset in the C code structure, and (if not) whether cobbling this in > is worthwhile, I haven't investigated or formed an opinion. I have already started some experiments. At first glance there doesn't seem to be any straight-forward way of doing this, but I'm not familiar with the code either, so it would take a while for me to reach any conclusion. Either way it seems clear to me reorganizing the code to make it at least possible will remove many of the weird checks and corner cases scattered all over, or at least make them more understandable. We'll have to see. Cheers. -- Felipe Contreras