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 25908 invoked from network); 11 Nov 2020 16:13:37 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Nov 2020 16:13:37 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1605111217; b=S+2iQGNrKkNvsLPfwjDu+sOBWxdm4w09np2HuWT4JhfFcZ9enI9zq95+/7Pgo/ZvcFtLKVEf9P CoAOpibpr/Cx5DeJoexiRUX5AbCtKVUZHk7yW5eyHeRk/WpjN2IPLw2nDTmQfI4DcbAQPLNeqs usbUKo7wqodj0X3tx3ad/pYQ/SMuAHFiqExyB6tD5tnhRBbwVK1JPH0absT55HMCCIRED7HlA+ KEOVKNCRTF794sO9P8QSDl2lLwmk3XbW2AAEWW+6zeskJ6BUMk37iPjCgTYzKIthiaKMBIl/63 vYymW8YZyfM6/yueNxwHKyp6Vq0dXAoKh3hHhbJaBptuAg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-il1-f175.google.com) smtp.remote-ip=209.85.166.175; 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=1605111217; bh=wLSHYa1nXPjCFfdB8C71L8NrJdZELxDtaLioSWLfTdo=; 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=dg658qaNjE1Cam9h8JObOErs6kQzv7Q91sOBs1fYN0F/e2aaOjSWxb4BCQAvfiUIOBg4RUYf0u F8gA02PMWbV5tnwY88pb3EkQHRjgG4oq87Q8fe5b5sOt1Pfvqo4f/nZNIdYFNNuvH0LlkfyHej bS3ZOz7gnUXxiteCcUwrGWxqKzmUbWI3AMXvzodU3kVJ9M4DApYzRxwNtCZKNWePjZw+cgyTeo u/oYuqSy/nN3GGFNEv/BT9RwC3RdDJ+sqaWuDDn9KMPjGK0e7U1tdZtBJbaN6Wgk3IY37ReDtX ROnw18qlkZY6Iwn5F2n4+JSqz6l5hqydeqygrGdDxu07ZQ==; 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=jb7TN0+CUca6r0xAdM/008XQfKfdC1SY7s15i0j5P38=; b=H+NSi/gBOQ9n+q/lDID+VJZzkF DKKIX1lvP3AqDnM/8pVHkelAM+UuDElihr8kWWnMI/Xw8BBbAjX4G7ti+NqPku2ca2lO7SX/HnmII 67svWIj4XVccyjPVFxmu6WM8N2bcYBDoSP2tI+oFHxAn9Ekns9OM4zsPdYDeh0R+kR/npl5tCyi+2 5VUj3Lu389QC0V+/3VqActhf2TNgB2PmSX2rg+hHt92gHxFsr5p2Ta7Sft00dkg61yFIoW5LfFIU4 2BbCCerIS/3PJ2k3P7LzQofWHDyGFb5v59GX/VXCkctgDO27zHvzuhTWkng/HK3dkEVhJW3BrSsTN HfZsX+lg==; Received: from authenticated user by zero.zsh.org with local id 1kcskY-000LDI-GP; Wed, 11 Nov 2020 16:13:34 +0000 Authentication-Results: zsh.org; iprev=pass (mail-il1-f175.google.com) smtp.remote-ip=209.85.166.175; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-il1-f175.google.com ([209.85.166.175]:38638) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kcskG-000L3W-JH; Wed, 11 Nov 2020 16:13:17 +0000 Received: by mail-il1-f175.google.com with SMTP id e17so2463994ili.5 for ; Wed, 11 Nov 2020 08:13:16 -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=jb7TN0+CUca6r0xAdM/008XQfKfdC1SY7s15i0j5P38=; b=B4g7NdlMUTlHeBHHScniiIbGfWRAC/LwaJ0ON0VDpqgSxvhMA0io/FSbiBDhLBNyHO yD8bneEIVQBOY+BP4ggg34LiOd99bL/oDVMwsZrplY7+TJ1Pp68vNNjhDmHD2gk6xtJ7 Rw14PzdARObmxwrZkISGP4BLALOCH/6dESQBiH7C7IMSIjM6KfXdzXjUetve3az+rANX P7a/AXb8nfpUSzx6wB6lsmnAFw3F5tOAGVvk5h+etJJyGSMZlgpFGwS+N6JVTxo7PjFL c69qES9cMPr/HAgf9sk7qBeVDuFdWrSMJ6Cbp4IwnFiaF7xYj4LPoofddXRZRtDoSTSw cp2A== 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=jb7TN0+CUca6r0xAdM/008XQfKfdC1SY7s15i0j5P38=; b=k7IkPrbV+8FRfjLTjK4J/WOm8B3pTXpjynxMMzB2Nkxgn/YHFc1p2/pItyuR2JowPd vzRyfe2Wld2ai3SLkMpZgno/qequF38WeaY1m8POA/BzNDaTTORYB8KQ58FBj90dHdXV Rp9T9ByCiSUTUkHFDfvR8etbX3/fCd1pOC2uS++lvVVT4y77IfyDg7+/ymVH05fO59Ek Flr935IawYGLvr3AfD/WtX0TVh+OYkCuSR6likIK85KE2pCfLQCkkMFhmWNn6gg5GlmV +IwkmPxg+KnF4/cuSpSZKzggh5xXX/r0toM/Ha3Gqwk0PilNTvg2U7Z4EvuyVToxTtha vKiQ== X-Gm-Message-State: AOAM531+I8UdJpkriaR2Fn2NP+WOULcCHtqyWmLlOdvwhp4qX4OTe/ks mEBsm8i4oy8JSOr/i9SJnaqJ8afwMSdwKjLbSi4= X-Google-Smtp-Source: ABdhPJwZFB0R1D76loPi0E0F/7g0d85dnw/SjoDSZh/XGcmeu6exz8a/hWCHNf+YBmR+5aYwRfaxelP+snBu0bS4+kY= X-Received: by 2002:a92:a1c8:: with SMTP id b69mr16999449ill.186.1605111194982; Wed, 11 Nov 2020 08:13:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Wed, 11 Nov 2020 17:13:04 +0100 Message-ID: Subject: Re: Bug with unset variables To: Felipe Contreras Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47532 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 Wed, Nov 11, 2020 at 4:57 PM Felipe Contreras wrote: > > Hello, > > It's obvious what this code should do: > > foo () { > typeset var > echo "var: '${var-other}'" > } When foo is invoked, based on the documentation for typeset, I would expect it to print "var: ''". Except as noted below for control flags that change the behav- ior, a parameter is created for each name that does not already refer to one. And indeed that's how foo behaves when I invoke it in zsh 5.8. > I also tried with the other unnamable shell, and the correct output is shown. I confirm that in bash 5.0.17 function foo prints "var: 'other'". However, I'm not sure whether this behavior agrees with the documentation. >From `help declare`: Declare variables and give them attributes. [...] When used in a function, `declare' makes NAMEs local, as with the `local' command. >From `help local`: Create a local variable called NAME, and give it VALUE. As far as I can tell, there is no indication anywhere in the documentation that omitting =VALUE will cause `local` to not create a variable in bash. Do you believe the behavior of bash is expected while zsh behaves incorrectly? If so, why? Roman.