zimfw/src/stage2/50_zimfw_check_dumpfile.zsh...

23 lines
1.0 KiB
Plaintext

_zimfw_check_dumpfile() {
local -r ztarget=${ZIM_HOME}/.latest_comp zpre=$'*\0'
local zdumpfile zline ckline=
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
if [[ -r ${ztarget} ]] ckline=$(command cksum < ${ztarget} 2>/dev/null)
local -r zfpath=(${${_zfpaths#${~zpre}}:A} ${fpath:|_zim_fpath})
local -r zcomp=(${^zfpath}/^([^_]*|*~|*.zwc(|.old))(N:t))
print -R ${(o)zcomp} >! ${ztarget} || return 1
if [[ -e ${zdumpfile} ]]; then
IFS=$' \t' read -rA zline < ${zdumpfile} || return 1
if [[ ${zline[2]} -eq ${#zcomp} && ${zline[4]} == ${ZSH_VERSION} && \
$(command cksum < ${ztarget} 2>/dev/null) == ${ckline} ]]; then
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Already up to date"
else
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b New completion configuration needs to be dumped. Will do %Bclean-dumpfile%b."
_zimfw_clean_dumpfile
fi
else
_zimfw_print -PR "<%= okay %>%B${zdumpfile}:%b Not found"
fi
_zimfw_print 'Done with check-dumpfile.'
}