_zimfw_check_version() { if (( ${1} )); then # Get latest version (get all `v*` tags from repo, delete `*v` from beginning, # sort in descending `O`rder `n`umerically, and get the `[1]` first) if (( ${2} )); then # background check if [[ -w ${_zversion_target:h} ]]; then print -R ${${(On)${(f)"$(GIT_HTTP_LOW_SPEED_LIMIT=1000 GIT_HTTP_LOW_SPEED_TIME=30 command git ls-remote --tags --refs \ https://github.com/zimfw/zimfw.git 'v*' 2>/dev/null)"}##*v}[1]} >! ${_zversion_target} &! fi else # foreground check local tags tags=$(command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*') || return 1 >! ${_zversion_target} <<<${${(On)${(f)tags}##*v}[1]} || return 1 fi fi if [[ -f ${_zversion_target} ]]; then local -r zlatest_version=$(<${_zversion_target}) if [[ -n ${zlatest_version} && ${_zversion} != ${zlatest_version} ]]; then _zimfw_print -u2 -PR "%F{yellow}Latest zimfw version is %B${zlatest_version}%b. You're using version %B${_zversion}%b. Run %Bzimfw upgrade%b to upgrade.%f" return 4 fi fi }