zsh-users
 help / color / mirror / code / Atom feed
* local but persistent integer?
@ 2022-09-16 15:19 Ray Andrews
  2022-09-16 17:44 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Ray Andrews @ 2022-09-16 15:19 UTC (permalink / raw)
  To: Zsh Users

This works in my function:

     if [ "$1" = "start" ]; then
         integer -x start="$(( $(date +%s%N)/1000000 ))"
         return
     fi

     if [ "$1" = "stop" ]; then
         start=0
         return
     fi

     [[ $start == '0' ]] && echo "Timer not properly started" && return
     ... code

... I need 'start' to persist between function calls which it does but 
it would be nice if it could be local as well since it has no use 
outside this function.  Also, it would be more hygienic to kill the 
variable entirely in case of 'stop' rather than set it to zero.  I tried 
'unset' but it didn't seem to work.  This will be doable of course.  
Very minor issues but I'd like to be able to do it properly.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-17  1:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 15:19 local but persistent integer? Ray Andrews
2022-09-16 17:44 ` Bart Schaefer
2022-09-16 19:43   ` Ray Andrews
2022-09-16 21:41     ` Bart Schaefer
2022-09-16 21:50       ` Ray Andrews
2022-09-17  1:51       ` Ray Andrews

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).