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

local but persistent integer?



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