zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: local but persistent integer?
Date: Fri, 16 Sep 2022 12:43:29 -0700	[thread overview]
Message-ID: <b1a20d70-bf98-04f4-e401-9521152d03cd@eastlink.ca> (raw)
In-Reply-To: <CAH+w=7bxYiss1853OBFsKzxAOYV66XnB5QeZUi=pDWp=q0==0g@mail.gmail.com>

On 2022-09-16 10:44, Bart Schaefer wrote:
> On Fri, Sep 16, 2022 at 8:19 AM Ray Andrews <rayandrews@eastlink.ca> 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.  "integer -x" within a function
> puts something in the environment (so visible to external processes),
> but it's still scoped to the function and goes away when the function
> finishes.
I must  be misunderstanding:

    #!/usr/bin/zsh

    function tt ()
    {
    integer -x unique_to_tt=2
    }

    8 /aWorking/Zsh/Source/Wk 1 $ echo $unique_to_tt


    8 /aWorking/Zsh/Source/Wk 1 $ . temp1; tt; echo $unique_to_tt
    2

... so it's visible externally as you say, but it's not going away either.



  reply	other threads:[~2022-09-16 19:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 15:19 Ray Andrews
2022-09-16 17:44 ` Bart Schaefer
2022-09-16 19:43   ` Ray Andrews [this message]
2022-09-16 21:41     ` Bart Schaefer
2022-09-16 21:50       ` Ray Andrews
2022-09-17  1:51       ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1a20d70-bf98-04f4-e401-9521152d03cd@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).