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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13542 invoked from network); 24 Nov 2020 00:52:58 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 24 Nov 2020 00:52:58 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1606179178; b=csjxrayj3eKe2w8lai/+njoL2f4AIWnC8Wo2PMD4X4z++572mNpSP+pRItFaU3Z8OeJFnA1Vtr HhQyac4FXC6dPn1d1ahYPG/f+MBEGmIKYd8dLESxv60mmAgBQQsaHz9tCuJoBpHg8ZI3ovmTvc MlshIwaSWpCUwENtNdsxiMsueKq7UmzERISO1QY59kBLQZQ13EUnJKaYCIsM12UtK/S26bn6r6 gy7QFXRuFLpTmjsCQuod+3ko1CExz2UPLEYPpkfF2GyaTEp2F0U7IchMGoPUaxF3N1m7tmffL5 s0yaDCuM/8pZFkvQpwEhKxi0f4WofvhNQGZmCWvtV0yMEA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f172.google.com) smtp.remote-ip=209.85.167.172; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1606179178; bh=EcTH1oqoMYCixyNyzuFLAHZp6f4LS8RZv5Em7eYV1Og=; 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=KqZXAvF6j8wc0KrHyHJvh4mKYAbO/Ja//ZVU0F1urP+G3Iw0+Ko6O8NV1N/Ts8rk3afC4QBN7m ystTk2zfoU86/++UukDfEyPE4bD06y/+5OxDhIjmBOBnSYKClerQysz7fD7/DkiHpLsOf2D0NX MSbVjPqBqE4PBn2jlz5nkZwz2bJLFsKEqcuHUrsklurn7OnkmdjuPqjv95Bpvxue9dhWwR88aX qX/IoMk9tmYzxl9w5mc4w+gTRbEJjONLKH+HsQ2sKJHG7zTEFVkQYcgbF8BfeLp+peA2nh74WV cFdBPtMgtgRfPPOFBNrCiMgsrttol3IS9YDb3NP53kIXiw==; 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=Nj9b2qQVAyz3Bdm8G0sQuNS7q7b/kwygel0JGUkcVdI=; b=gaDoqpeSvRasdlqGarfuuqjTIe e6IiXPkH/CXozdSIGrYrcMc8npfcOAJo7M0IN9YZZdn/1VHEGCtcci4F5mM8sl0Zwy/byLcivlSS2 /ImFLjAaJp3Z4DVe/e6suGQ2OPjiQC+Ehcoo9Yz+p4JdiLdplTR/cGHF5in2rtTSAZP70fSxpvXwt KJc2kaoFILglmkFyr6gY2zmQa7vvOPa6s3en0QuHeDo0nBLhNqWbdU/yq4SRg3rapfo8Guo95eorH AuQV+ejTY3NNQddX9hAFfW5QvMO6+6NQLnJO8vO0V0cnHHRgBadrVP48Zpg8q3q6UQYvaZhpkwu+M fDoGlbKw==; Received: from authenticated user by zero.zsh.org with local id 1khMZl-0005x2-QL; Tue, 24 Nov 2020 00:52:57 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f172.google.com) smtp.remote-ip=209.85.167.172; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oi1-f172.google.com ([209.85.167.172]:40710) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1khMZQ-0005nZ-VL; Tue, 24 Nov 2020 00:52:38 +0000 Received: by mail-oi1-f172.google.com with SMTP id a130so13768799oif.7 for ; Mon, 23 Nov 2020 16:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Nj9b2qQVAyz3Bdm8G0sQuNS7q7b/kwygel0JGUkcVdI=; b=jJyKyeo7yo1Z9+zn/bz/xzat26hY9tuw2Mys/LhkfQhK75Gg4Jx89QNGEFpCSmKQLd jUVCiJs5aMrLgiV72mBjef6u5K0IPwXiM2Rn0QP9UtHcfSqFfZzsfSU1hnZ8aii44Slr vP6LVDft+zx01/DcHbNSOshWbHotkjukY3tcHWdwDKNncPnZFdtnNc4RI5IkW7dgLUiE J7M6R1oZGKrf0U8zZYUURBbd+dqSgV5Kt7c8O7y1ZoU6FoUl4ytUwygbqd9TtvV3qcX0 OPrLYbxn+XY+qGMO26Gy3Bwh5HfuQE+kCN9AE4E+s5ZFPW096nZ31fAQXbO+B8PF3HvW Zn5A== 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=Nj9b2qQVAyz3Bdm8G0sQuNS7q7b/kwygel0JGUkcVdI=; b=bj4DxGczEBw0S0MDOYpoNAkYlUWyYyXpnIkzbgpv42PsV8inAOAWHJjP0B32BPCxEL GTMnf3YkrvlWPBOgZqOIubaKvtFLWLXSsfY6NFeQ2hOoBU7weBUSBq3hqi/VTyY//e9T jCRjgP4yYNmVfMXgYAO/y6ycTeOcHzFRMSj9VnDiuyar3JGNH6CIUoExf+HrPPTHL5oL 58RgSJ0TrO8hkRkG57m+cEPLnZfIp7MSLVSacHjirz0glWOwNqXsOsrV5Lz9fdvTUiFK 4RGrnGVUvddmsgnKgZToFmJJ0wvu9fndigBEJmbt2N65i/n06X5dXIva/hYMlx3xHi2D pB3Q== X-Gm-Message-State: AOAM533Os7idyp5kqfbKlsqalCV5G0yo484CkO7iQgKKYbjB3VoHChjR y9kIxm/zjkd/VK4cQpEoxcVVnn/PdoCImWFkgT9UWg== X-Google-Smtp-Source: ABdhPJxyABht8EqtSBupLOSYKXaLCe9zE4i+Udn5yHKmeiXq59dp7cT/Xr5W1wGb5XDycieJq7bYR6iQiTFIvErOlWs= X-Received: by 2002:aca:bd45:: with SMTP id n66mr1163931oif.132.1606179155868; Mon, 23 Nov 2020 16:52:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Mon, 23 Nov 2020 16:52:24 -0800 Message-ID: Subject: Re: Bug with unset variables To: Felipe Contreras Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47612 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 3:39 PM Felipe Contreras wrote: > > My argument is about the consistency from user's perspective. Consistent from what user's point of view? One coming to zsh from other languages or one long familiar with zsh? Because zsh development has consistently (ahem) sided with the latter. > 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} > } In the first case, $var is a global, so the behavior of ${var-other} is unknown. It's not possible to write deterministic code. In the second case, there's a knowable behavior of ${var-other}. That behavior doesn't match your expectation, but it's well-defined. To make the first function deterministic, it is necessary to write: func () { unset var [[ -n "$1" ]] && var=$1 dosomething ${var-other} } Whether one should expect "typeset var" to imply "unset" is how we ended up in this discussion.