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 30193 invoked from network); 25 Nov 2020 07:02:42 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Nov 2020 07:02:42 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1606287762; b=J7ZxHTbVjww/o/ocLSveZ0aXBVxhAbuzUrxH0Ku4/JzKeDFY9Ibmzyl05kH10hUjD2fQRR2PMN FBZXY/DvXTpPF7tXZf/JZdkurb36jT6oTbTuiWprxqJ3nvVAvQ1Zf7ZFRgJQwLeaY1BP7cjeDR vX1B1a+Sl6HOB8PGVwQCxA0ZmzSZwNCliQikK4tSAY20j1+gmq0HTXBAHT4jOQ3veVAcJ278FM siUcFT4WgPQ8xKBV71TwZ5HhA+Fgt7oeRdTkjUj14u+1UmPEDYu3hbz6/JvtBl2c8ziNQOFDtC p8M2yLFLidPkEpV8kNkOliNcj89LwvGyUQcNKEtYJnYvog==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f50.google.com) smtp.remote-ip=209.85.210.50; 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=1606287762; bh=cgcRpT5wwpP2lbq6+/uxxJnTo4zScAirb+kVkSca+3E=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=VwNOwfcZQC5BC1HU4ACq6glr6uiiEmXYVNoJD14jC7UrRlRUy4wUHrbPFAkL12EKUb82zP49PR 3y9NG4mgiODu3o0INu6bQaNW4PFGr9JOfGKJl3k6XJR21tk7vH+zz3FecSwtD95X4E+oaI2DJ8 Kr7ak4i6HRoswr+oo2oUse9VTatmg5zULNXb8DTi+Jj1MK3uFwzwZ1r0F+gr64qRd/SGA9BrLI rJVpuHB/JJAtTLO3Uh0n5BYCpRlifeSm9zwNQCpV58DwRXnVrOr+ec2pP9Fyk6EaWDeR9phiKa awPjm2smTx8gqW4AEYqjbfGbaMOCxO+ZdZa3kIuBTcqqsA==; 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:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=p93o2msBCT00RoTNmQPHsQsdq0yzqEzOw74C54hvQeI=; b=HYU0607AnodsC0YiaCYhiZ2lFV hCDH14UUXKKftx0cJBruXpp65ugIQ7jDnD6WID0RbpBPzsiSYyfyjnDgkFqoMUsOFEl/zc9LytCKA ZfXXrz9YLVoDPWB1nen0kl3wQ0w+vRRltTORKo72T/zyIJsemRSObQTRa6bAdb3R2ibz6pVPTsjUT 6p2IQ20t9rfu9o5gMmA4GmAL5ktuvur/OQOMXdba1n7Ni9UZ1cd4KS1essRX2DH8I2oE3jPNlxP6p u/4LJ+j3j4fejNzmWCpzuT7VIuWqs2gvZQyWikYGwUM7pSSB6TNm48+FN9zV2i+FKcpfVnf6wRIc7 /UkeGDVQ==; Received: from authenticated user by zero.zsh.org with local id 1khop4-000CGS-UG; Wed, 25 Nov 2020 07:02:38 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f50.google.com) smtp.remote-ip=209.85.210.50; 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-ot1-f50.google.com ([209.85.210.50]:46326) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1khook-000BWP-DN; Wed, 25 Nov 2020 07:02:20 +0000 Received: by mail-ot1-f50.google.com with SMTP id g19so1294036otp.13 for ; Tue, 24 Nov 2020 23:02:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=p93o2msBCT00RoTNmQPHsQsdq0yzqEzOw74C54hvQeI=; b=iCHk3fA36SUFiQj9JKOt0gJW37j0ey3lAjZwwNx0qeegCq8IvZ2r39dIALWyXnzAFk Zd+z9zU5YjvB+7VPC2NWzPWyhcN2MvS05GyPKUPQ7waS1H0GRUkzzcqDpi7ocuoeV0pH Npx8bgThOst2yabTU8lmFaoRYIpDd9lrRvf+2HiblV2AdG4ijn/tuKal4ADj2g/aom1Z Yx0TeAkNQIi63cm6S+2OGcibjNw8emZ13fDHLORJ1HBRR5toOeGs0f6NAtmARqFSDA/t txWZQf4kxnoNvvOkQpDehYnV63pr/OqozaDlV5zuOX1P1VAvpS0Wt2c1qmPxu60TQeWO kACg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=p93o2msBCT00RoTNmQPHsQsdq0yzqEzOw74C54hvQeI=; b=MPD0ey91+mNHEucV/PvnJ3BYiKoRlJAy4EdRUqFfrDdCyrQd+jpATS+K7jUqOHJZUS Z74tKks4COcL9w64C3awa4rJqVwS+CKyL+pgnUAPBoAvH3zjasQDf6LC2dksphst8mZA 7SR/L3kQss5motpW+q1bLDC7sOVPx/4sovV1f+TN17Tx5EJX9ziwWtdLGjqdOZjbjGax oJ3wBn8sMY4wFi/Q3UwaxZzIjUU/HQwrzXrMs1FdEfHogn1iACpjmBCc0fblfQUp9dgP 1tHUIZ3EKPeQTbnMwvV8/JO0Vnt2Vx+gh4pgkE3dMh7Xy8JhvSHcr31TnyK0AdInFwkZ UT6w== X-Gm-Message-State: AOAM532uHTRV8WK1SwZl470Zn3QuRHD3J6Y5YJGqBiixJlte0CqEURZX UhQlpFwnE9wtgFjvkZIW8w1yihBP6vYV/l9tLbGdmivCoce9dQ== X-Google-Smtp-Source: ABdhPJze6CEFzT9d0QWt/cP2D5G/VdBuU/S5jIfeUqUyzMm98Gb4BmCt3XpZViqLlm4HK4/4HZivsfBKy6BhSxvNxJ0= X-Received: by 2002:a05:6830:1552:: with SMTP id l18mr1860729otp.229.1606287736531; Tue, 24 Nov 2020 23:02:16 -0800 (PST) MIME-Version: 1.0 From: Bart Schaefer Date: Tue, 24 Nov 2020 23:02:05 -0800 Message-ID: Subject: More rabbit-holes with unset variables To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 47622 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: I was experimenting with ksh to look deeper into adding behavior to ksh_typeset in zsh, and discovered that this example: function ff { echo start typeset -i i typeset -p i echo ${i-nil} unset i typeset -p i echo end } Outputs in ksh93: start typeset -i i nil end And bash: start declare -i i nil declare -- i end Although both of them have a way to represent "declared but not set", neither of them treats "explicitly unset" as equivalent to that, and neither of them preserves any type information across unset. Only bash regurgitates the "declare" after unset, but that's an effect of the implementation of -p rather than of the state of the variable, because function scope still applies to $a in both cases. (I had to remind myself that "ff() { ... }" in ksh is NOT a "function" in the sense of scope locality.) Therefore, this isn't as simple as having zsh create an unset variable when typeset is given no assignment, because subsequent assignment has to preserve the type of the variable, which normally does not apply after unset.