From 302759f82c1889c9d86a4c0648446858ee46d627 Mon Sep 17 00:00:00 2001 From: Ben O'Hara Date: Mon, 18 Jun 2012 14:18:39 +1000 Subject: [PATCH] remove the fpath entry if module fails to laod and only load functions if the module has loaded This also fixes the fpath not being set on zsh 4.26 on el5 by removing it from the function() --- helper.zsh | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/helper.zsh b/helper.zsh index 7c960b20..31f1d0b3 100644 --- a/helper.zsh +++ b/helper.zsh @@ -38,23 +38,6 @@ function omodload { # $argv is overridden in the anonymous function. omodules=("$argv[@]") - function { - local ofunction - - # Extended globbing is needed for listing autoloadable function directories. - setopt LOCAL_OPTIONS EXTENDED_GLOB - - # Add functions to fpath. - fpath=(${omodules:+${OMZ}/modules/${^omodules}/functions(/FN)} $fpath) - - # Load Oh My Zsh functions. - for ofunction in \ - $OMZ/modules/${^omodules}/functions/^([_.]*|prompt_*_setup|README*)(.N:t) - do - autoload -Uz "$ofunction" - done - } - for omodule in "$omodules[@]"; do if zstyle -t ":omz:module:$omodule" loaded; then continue @@ -63,13 +46,22 @@ function omodload { continue else if [[ -s "$OMZ/modules/$omodule/init.zsh" ]]; then + # Add functions to fpath. + fpath=(${OMZ}/modules/${^omodule}/functions(/FN) $fpath) source "$OMZ/modules/$omodule/init.zsh" fi - if (( $? == 0 )); then zstyle ":omz:module:$omodule" loaded 'yes' + # Load Oh My Zsh functions. + for ofunction in \ + $OMZ/modules/${omodule}/functions/^([_.]*|prompt_*_setup|README*)(.N:t) + do + autoload -Uz "$ofunction" + done else zstyle ":omz:module:$omodule" loaded 'no' + # remove the fpath entry + fpath[(r)$OMZ/modules/${omodule}/functions]=() fi fi done