Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: local but persistent integer?



On 2022-09-16 10:44, Bart Schaefer wrote:
On Fri, Sep 16, 2022 at 8:19 AM Ray Andrews <rayandrews@xxxxxxxxxxx> 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.





Messages sorted by: Reverse Date, Date, Thread, Author