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,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30942 invoked from network); 16 Sep 2022 21:42:40 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 16 Sep 2022 21:42:40 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1663364560; b=pY7nvtheP51frZ10o/g+mEKtONt9GTxGLJtIRoenrD66bLN2YLWtChB8TRknfc1Mb72YfVPRZT Ho8m7KpnA61Sy9yg78wqXGHMlEqb5qzX/zBIVXX66esFDRUE6E+V8EJprP83h/GXrCJdnSlwUC 6dwAPqpn0dgHXS6qj0T6zfczaiDWINjywPrEQgyOFAklFz2dZqS32LRIco3nw1NyShHPsgbj1d 4NBj2K5OjCtJcZV+57VyxLKxK3/UcgEcqYFQ5jkbd4llph92vLRXH7bI8wzKaTffyosgOZUtIj GJFHmGb+7LsjVlYbenpEOd4YPfrm8aEy2RQXRGtKzIUiyA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 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-20210803; t=1663364560; bh=ro6DxFAIdaTHUd/z5i4mHvozscbogXNsr7trbdIF+oY=; 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=fhJ4GwXT0+xEx/ZOf5QXusqDJbXVdxuI+mGRlC0bFduB4CMGLdDHn4eCPWLZrgV8/rCCvIOUGb dE7qa1aJbBRRZyFofcNz5tv0KvDdixIcED46BmOY2DUon2qLjDDlqLlp5X/zNRiP1NTGJwkYXC ghCJ2PehHWFU70tSeMQnaWtMHwI+0/lEd2XhxOrz8AfnC9Clfr5GhpcaBPx2jh9Ba+4IPLcHlv mSojZxjlR+VUGqbJr/2vimiveoOGzVfH+N0LR+uos4fqTKR/esrXbagzjHFpnBqr1h0XmPdYSu ivCqO5QjWIVuQwxvwAnAoDhhn87i1hoepBUSV4NcsCiz3Q==; 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-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=zylcDJrVfYdy5huEU2Fm/Yl8eHVhH1wmLhF/Apvn0aM=; b=UWUmb/g29VuHqTCpMkQDev8qP1 YHtfy5F2Xc3ZEcEnmefzaC4uRu4I1iMX3v3t+HXA+GW7jVJPVoa4ufvRMXIwKU+ANLLDVxmcRv8+9 8enOGJ9vBAxMfpRrlewRKVgvm2UBba7FM2x90ZhwnARXdNNp8pPBkwCBV1B5pKtQ+/1JazPSu0GCf rmSuWmG86yraAbjRmZrcaUB5BCGKXlgXAfMm+On2Zz8CwkPVD/wrmHqICvM1kVVlZI+liiqWU7I/N MBJF8hfzeTNSwIRFVrvL3N3JxRvM/CQnsAfb3DplD8Ip5+rvIhwaqsYv7bz71gfXVhRhK7FTLicU9 S9v2nd5w==; Received: from authenticated user by zero.zsh.org with local id 1oZJ6d-0009Xd-OF; Fri, 16 Sep 2022 21:42:39 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f46.google.com ([209.85.218.46]:42543) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oZJ5h-0008ph-8J; Fri, 16 Sep 2022 21:41:42 +0000 Received: by mail-ej1-f46.google.com with SMTP id sb3so22648843ejb.9 for ; Fri, 16 Sep 2022 14:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=zylcDJrVfYdy5huEU2Fm/Yl8eHVhH1wmLhF/Apvn0aM=; b=a5pHe0QuaImmzArqlDU2ImZ0RCnLTyJAcTTxkfjN/9DrD/IWGQF+3Y3WRsNlaYqiVu dUi0YlCHFS4c3pc7BLR0GL33PzmCQmHJ2Dq5tDAQhfJna54ZTIFtCgTUNIBrc6RHU38h NdwK2lspZZH5sKNk0VcpA70AzYjkXfBkro3qBdaGTVp79jfg+NOY+f3lS7eQwxJm8Cd6 ZnCAiSAHGR8GHXAppDxHUjS8MYuWSMqY/SIVOhW1EwCGvkYFTlCIYRACFCQRvIg1h3Q3 IcrxGuji7RB5suz+53YekfmCkOlk91OfjhzIGF/3qhGuuydQFLTH8CbjsWixiFRR6Y58 bE/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=zylcDJrVfYdy5huEU2Fm/Yl8eHVhH1wmLhF/Apvn0aM=; b=nT4F4efvAiR0hqgx9tqZEvzqCZIbaiOIn5jA4AbcLUMDKpR8I1+0DPHB8Ozy+VaaEg ycubzYGEGiXMh/ZlVERxjXBb1hbZkdT2nUEuq8EarX8nj0c+5QCXaZq4Tc6Jf2kY10Mj jUR6SUczYXvD9IS4WJpA33NuiRSBKBbyXTL8j6Ed9yTtQ2Trm9V3ozuSQZpNMyCrDJXe vesrpJC0q84vcm1bR5ISFfkpvBHGoxNP/OQmGePP56AwOkp6A6EEZu2PWR2lIqA3p5PJ jzjB4CC30dgHy6wIedenyJhMej3UhIVMPOB/ddGGKdqHeLHtxfD3R1n7b6zfvwd8WVQk V5bw== X-Gm-Message-State: ACrzQf3xKDvYAiVvNERxuYq/2cGPbye+eV1HdBP29QsIfH7QU3Dsv1gD 70C0/l5buUM/flCnCiKBnKN71F/8ELgIlh96/xIG7banjs4= X-Google-Smtp-Source: AMsMyM6Wvr6i+szJHsi4mzceVyysjLHh8h+/eXRNQcXwR6COnrkmbI9HF+rN9WmTKerE/1ZvV6HCGMJDpIKfVOZci2c= X-Received: by 2002:a17:907:a052:b0:780:c4e4:1715 with SMTP id gz18-20020a170907a05200b00780c4e41715mr1486494ejc.55.1663364500502; Fri, 16 Sep 2022 14:41:40 -0700 (PDT) MIME-Version: 1.0 References: <22a10f61-5f82-9797-4bc9-9082f9371dc7@eastlink.ca> In-Reply-To: From: Bart Schaefer Date: Fri, 16 Sep 2022 14:41:29 -0700 Message-ID: Subject: Re: local but persistent integer? To: Ray Andrews Cc: zsh-users@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 28101 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 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. 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.