24 lines
984 B
Plaintext
24 lines
984 B
Plaintext
_zimfw_upgrade() {
|
|
local -r ztarget=${ZIM_HOME}/zimfw.zsh
|
|
local -r zurl=https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh.gz
|
|
{
|
|
setopt LOCAL_OPTIONS PIPE_FAIL
|
|
if (( ${+commands[curl]} )); then
|
|
command curl -fsSL ${zurl} | command gunzip > ${ztarget}.new || return 1
|
|
else
|
|
local zopt
|
|
if (( _zprintlevel <= 1 )) zopt='-q'
|
|
if ! command wget -nv ${zopt} -O - ${zurl} | command gunzip > ${ztarget}.new; then
|
|
if (( _zprintlevel <= 1 )) print -u2 -PR "%F{red}<%= error %>Error downloading %B${zurl}%b. Use %B-v%b option to see details.%f"
|
|
return 1
|
|
fi
|
|
fi
|
|
# .latest_version can be outdated and will yield a false warning if zimfw is
|
|
# upgraded before .latest_version is refreshed. Bad thing about having a cache.
|
|
_zimfw_mv ${ztarget}{.new,} && command rm -f ${ZIM_HOME}/.latest_version && \
|
|
_zimfw_print -P '<%= done %>Done with upgrade.'
|
|
} always {
|
|
command rm -f ${ztarget}.new
|
|
}
|
|
}
|