From 1e7855ea63ae2bf1104ca9eb865ffca7250cf0c5 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sun, 15 Nov 2015 00:44:11 +0100 Subject: [PATCH] Only test for ~/.axzsh.debug once and export AXZSH_DEBUG This makes subsequent tests much faster and allows other tools to test for "debug mode" much simpler. --- ax.zsh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ax.zsh b/ax.zsh index a3c66c7..c2ed4d6 100644 --- 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=( -- 2.39.2