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.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32053 invoked from network); 16 Sep 2022 21:51:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 16 Sep 2022 21:51:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1663365096; b=FFeaU9uz+0uUMwE7vG9ozAwsxmqSOlYNSQG1oLc3H2aJwFgm53+b86FBFgEp3ltytoKB4DeRr+ 8BipGamRs/THLDPxZ9wUWF4Vk43va9m1LJzibGGijAQ19o6725ThBRu2bUf1jgDP1tmUgZm2BL iv8izGRu2McBgp4jPL8r7NjQKqIVl7o1XjVovGZ95BdNA0xR8IE2bbzTKwpyZoqbnpB0BKNZSD 1Gp0aQMzTN8uJtvbKBZ1yyvi31bd3nQ/OZggPOKJm5D8/9VNB+9C2UosrRESjJwWdySBqlQ2Rs ff6I6Ox5GYyByGEevK4WG6xC5r6UpgCXCQCZcKT98dkvvg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1663365096; bh=mYAOFEgdwAnpx8NPdiSWuR8oSaReHlRKnvfcuKrnXJg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature; b=H8fbLUkNzbNZ3S9W/Govh9aKLonWG23G5stXpJ926zu5ge/crHFhEPILwQYkmcw2QPhtrXmCW8 I70FjW+F4iLb5tKtdp6sxPhhK2C4yldkOsuFL1lcGK56VHT5bBEFhhqH/kWi/WMU9DWA2THlb7 ZeUszupadTxvaivGSUwjbxmVBH59+iE2pbfq8OMgZzU/kNtlbsJXYrhD9+6gDLJIkMmZR2aUzQ 7/bKWQvP3E59IUuSuLYlEKb6Ls0/GE+7NH+0IFLu4gU5MZI9Mh8temktsFPV7sFN85vCie5urk +7eLQdT692zx3VmewdJ3wWS2cmJrbDNup1m8VkIZjVgAqQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-transfer-encoding: Content-type:In-reply-to:From:References:To:Subject:MIME-version:Date: Message-id:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=OPBfbeASnWs87SBcv/HJaUYt4MB8ajYrdYiVsEhRaKg=; b=rD2Bv2q7kEk/0TB6E4wOWF3mX5 oMZoB7EgtHu4gYQc+K35s+fYy9mYkKjgV694uN0c222Tiv5Jad3FylU5xZxnwXrhUySjaAUMftZm+ m8iZFx/N8RzXfECB7gnIuqWjktGWo4kzCPhEqxktNa5G7gRsrVjpGa2pNlxHt8KXQcQscVBGSQcBh ZEleY/ldQgMyjurXoCMhMXPMoe/BsC54hS0TL7OiMP5PW60F7fag00giXmNWfWkhBQapkz7o/nVyw TVYHG64r/GSdZbkaqGHvwz3wVBKSANXCw8wi5EDUjQU0b8uu2khKX4GjfaUzdt9HLKe7j9SOI5CFZ HWBFIlCA==; Received: from authenticated user by zero.zsh.org with local id 1oZJFH-000AvI-Te; Fri, 16 Sep 2022 21:51:35 +0000 Authentication-Results: zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none Received: from mta03.eastlink.ca ([24.224.136.9]:44296) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1oZJEB-000ADp-3g; Fri, 16 Sep 2022 21:50:27 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta03.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0RIB00JY6O0PJE31@mta03.eastlink.ca> for zsh-users@zsh.org; Fri, 16 Sep 2022 18:50:25 -0300 (ADT) Received: from [192.168.0.3] ([24.207.18.108]) by Eastlink with ESMTP id ZJE9oBolnFC8dZJE9ofkss; Fri, 16 Sep 2022 18:50:25 -0300 X-Authority-Analysis: v=2.4 cv=HaHR8gI8 c=1 sm=1 tr=0 ts=6324efa1 a=xN66ZtSbq5jdJYpBp7G/jQ==:117 a=xN66ZtSbq5jdJYpBp7G/jQ==:17 a=IkcTkHD0fZMA:10 a=gir0-LH0AAAA:8 a=3NJvo2U2FygzcXO3_ywA:9 a=QEXdDO2ut3YA:10 a=aLewGyoHDmJ4ULJHWpSz:22 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvuddgtddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfgrhicutehnughrvgifshcuoehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgeqnecuggftrfgrthhtvghrnhepiedtjeffvefgtdehgefgteekueeggeeitedutddvvdduteetffdvveelgfeukedunecukfhppedvgedrvddtjedrudekrddutdeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrddukedruddtkedphhgvlhhopegludelvddrudeikedrtddrfegnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-IP-NOAUTH: 24.207.18.108 Message-id: Date: Fri, 16 Sep 2022 14:50:24 -0700 MIME-version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: local but persistent integer? Content-language: en-US To: zsh-users@zsh.org References: <22a10f61-5f82-9797-4bc9-9082f9371dc7@eastlink.ca> From: Ray Andrews In-reply-to: Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 8bit X-Seq: 28102 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On 2022-09-16 14:41, Bart Schaefer wrote: > On Fri, Sep 16, 2022 at 12:43 PM Ray Andrews wrote: >> On 2022-09-16 10:44, Bart Schaefer wrote: >>> On Fri, Sep 16, 2022 at 8:19 AM Ray Andrews wrote: >>>> integer -x start="$(( $(date +%s%N)/1000000 ))" >>>> >>>> ... I need 'start' to persist between function calls which it does >>> Given that construct, it should not. >> ... so it's visible externally as you say, but it's not going away either. > Hm, this is possibly a bug, but it's also possibly an expected > side-effect of "export" that I've forgotten about. My previous > statement is correct for string-scalars created with "typeset" and > "local" etc., but "integer" behaves differently. Counter intuitive for sure.  I'd call it a gotcha. > I think this is > related to preserving the attributes of the variable (i.e., even if > unset, it remains an integer, so if you assign to it again it acts > like one) about which I believe I recall some discussion, but I don't > recall when it was implemented. > > In any case it's not reliable to expect locally-declared variables to > behave this way, and I'd still recommend using -g or -gH instead of > -x. Ok, I'll experiment with that, tho at the moment what I don't know isn't hurting me. Thanks Bart.