6129062139
instead of allowing xargs to execute the action with no positional parameters. Also don't try to write to .latest_version if there's no write permission. This is supposed to be a background/optional operation, so we don't want to show an error message in this case. And use Zsh globs instead of find with -exec, and find won't fail if there's an error with the -exec command.
19 lines
850 B
Plaintext
19 lines
850 B
Plaintext
_zimfw_version_check() {
|
|
if (( _zprintlevel > 0 )); then
|
|
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
|
local -r ztarget=${ZIM_HOME}/.latest_version
|
|
# If .latest_version does not exist or was not modified in the last 30 days
|
|
if [[ -w ${ztarget:h} && ! -f ${ztarget}(#qNm-30) ]]; then
|
|
command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*' | \
|
|
command sed 's?^.*/v??' | command sort -n -t. -k1,1 -k2,2 -k3,3 | \
|
|
command tail -n1 >! ${ztarget} &!
|
|
fi
|
|
if [[ -f ${ztarget} ]]; then
|
|
local -r zlatest_version=$(<${ztarget})
|
|
if [[ -n ${zlatest_version} && ${_zversion} != ${zlatest_version} ]]; then
|
|
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"$'\n'
|
|
fi
|
|
fi
|
|
fi
|
|
}
|