]> arthur.barton.de Git - ax-zsh.git/commitdiff
Only test for ~/.axzsh.debug once and export AXZSH_DEBUG
authorAlexander Barton <alex@barton.de>
Sat, 14 Nov 2015 23:44:11 +0000 (00:44 +0100)
committerAlexander Barton <alex@barton.de>
Sat, 14 Nov 2015 23:44:11 +0000 (00:44 +0100)
This makes subsequent tests much faster and allows other tools to
test for "debug mode" much simpler.

ax.zsh

diff --git a/ax.zsh b/ax.zsh
index a3c66c768c1f828a572cd4994c7bfc59d3fdd837..c2ed4d6c3e7edce41f1555285e775510d3de75a8 100644 (file)
--- a/ax.zsh
+++ b/ax.zsh
@@ -4,8 +4,6 @@
 script_name="${${(%):-%N}:t}"
 script_type="$script_name[2,-1]"
 
-[[ -f "$HOME/.axzsh.debug" ]] && echo "» $script_name:"
-
 # Load plugin code of a given type.
 # - $1: plugin name
 # - $2: plugin type (optional; defaults to "zshrc")
@@ -17,7 +15,7 @@ function axzsh_load_plugin {
 
        if [[ ! -d "$dname" ]]; then
                # Plugin not found!
-               if [[ -f "$HOME/.axzsh.debug" ]]; then
+               if [[ -n "$AXZSH_DEBUG" ]]; then
                        # Show error message for all stages in "debug mode":
                        echo "AX-ZSH plugin \"$plugin\" not found (type \"$type\")!" >&2
                elif [[ "$type" == "zshrc" ]]; then
@@ -45,7 +43,7 @@ function axzsh_load_plugin {
        fi
 
        if [[ -r "$fname" ]]; then
-               [[ -f "$HOME/.axzsh.debug" ]] \
+               [[ -n "$AXZSH_DEBUG" ]] \
                        && echo "   - $plugin ($type) ..."
                source "$fname"
        fi
@@ -59,11 +57,15 @@ function axzsh_load_plugin {
 if [[ -z "$AXZSH" ]]; then
        export AXZSH="$HOME/.axzsh"
        if [[ -f "$HOME/.axzsh.debug" ]]; then
+               export AXZSH_DEBUG=1
                echo "AXZSH=$AXZSH"
+               echo "AXZSH_DEBUG=$AXZSH_DEBUG"
                echo "AXZSH_PLUGIN_D=$AXZSH_PLUGIN_D"
        fi
 fi
 
+[[ -n "$AXZSH_DEBUG" ]] && echo "» $script_name:"
+
 # Setup list of plugins to load:
 typeset -U plugin_list
 plugin_list=(