]> git.donarmstrong.com Git - zsh.git/commitdiff
use a loop to define functions
authormartin f. krafft <madduck@madduck.net>
Tue, 6 May 2008 20:40:58 +0000 (21:40 +0100)
committermartin f. krafft <madduck@madduck.net>
Tue, 6 May 2008 20:40:58 +0000 (21:40 +0100)
.zsh/zshrc/99_hook_functions

index a934d04f2231846704d83fcdf84522de284d7d5e..34abb0e72284cc86e1aac23dd7f9f7ee25c846cc 100644 (file)
 
 autoload -U is-at-least
 if ! is-at-least 4.3.6; then
-  precmd() { for fn ($precmd_functions) $fn "$@" }
-  preexec() { for fn ($preexec_functions) $fn "$@" }
-  chpwd() { for fn ($chpwd_functions) $fn "$@" }
-  periodic() { for fn ($periodic_functions) $fn "$@" }
+  for i in precmd preexec chpwd periodic; do
+    if [ -n "$functions[$i]" ]; then
+      warn "$i function already defined"
+      continue
+    fi
+    eval "${i}() { for fn (\$${i}_functions) \$fn \"\$@\" }"
+  done
 fi
 
 # vim:ft=zsh