1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-04 10:41:11 +02:00
zsh/Functions/VCS_Info/VCS_INFO_hook
Peter Stephenson 4523ff9383 Frank Terbeck, Seth House: 27712, 22713, 27714:
VCS Info hooks and Mercurial improvements
2010-02-16 10:47:06 +00:00

42 lines
1.1 KiB
Bash

### vim:ft=zsh:foldmethod=marker
## Written by Frank Terbeck <ft@bewatermyfriend.org>
## Distributed under the same BSD-ish license as zsh itself.
local hook func
local -x context hook_name
local -xi ret
local -a hooks
local -i debug
ret=0
hook_name="$1"
shift
context=":vcs_info:${vcs}+${hook_name}:${usercontext}:${rrn}"
zstyle -t "${context}" debug && debug=1 || debug=0
if (( debug )); then
printf 'VCS_INFO_hook: running hook: "%s"\n' "${hook_name}"
printf 'VCS_INFO_hook: current context: "%s"\n' "${context}"
fi
zstyle -a "${context}" hooks hooks || return 0
# protect some internal variables in hooks
typeset -r vcs rrn usercontext maxexports msgs vcs_comm
for hook in ${hooks} ; do
func="+vi-${hook}"
if (( ${+functions[$func]} == 0 )); then
(( debug )) && printf ' + Unknown function: "%s"\n' "${func}"
continue
fi
(( debug )) && printf ' + Running function: "%s"\n' "${func}"
${func} "$@"
case $? in
(0)
;;
(*)
break
;;
esac
done
typeset +r vcs rrn usercontext maxexports msgs vcs_comm
return $ret