Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
local but persistent integer?
- X-seq: zsh-users 28098
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: local but persistent integer?
- Date: Fri, 16 Sep 2022 08:19:04 -0700
- Archived-at: <https://zsh.org/users/28098>
- List-id: <zsh-users.zsh.org>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author