From: Ray Andrews <rayandrews@eastlink.ca>
To: Zsh Users <zsh-users@zsh.org>
Subject: local but persistent integer?
Date: Fri, 16 Sep 2022 08:19:04 -0700 [thread overview]
Message-ID: <22a10f61-5f82-9797-4bc9-9082f9371dc7@eastlink.ca> (raw)
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.
next reply other threads:[~2022-09-16 15:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 15:19 Ray Andrews [this message]
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
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=22a10f61-5f82-9797-4bc9-9082f9371dc7@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).