From c3ccdced26ff5d9baf36858968701e7b12447cd6 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 8 Feb 2009 16:48:58 +0100 Subject: [PATCH] Add more debug output. Useful when debugging which file gets loaded. --- bash/rc | 8 ++++++++ shell/env | 6 ++++++ tests/source_config.test.out | 2 ++ zsh/env | 8 ++++++++ zsh/rc | 4 ++++ 5 files changed, 28 insertions(+) diff --git a/bash/rc b/bash/rc index 48b6433..942ac8d 100644 --- a/bash/rc +++ b/bash/rc @@ -7,12 +7,18 @@ host=$(echo $(hostname) | sed -e 's/\..*$//') # Load environmental related settings used by all shells. if [ -f ~/.shell/env ]; then source ~/.shell/env +# Fallback functions as ~/.shell/env couldn't be loaded. else + function source_debug() { + echo $@ + } function source_config() { echo "Couldn't load source_config(), can't source files." >&2 } fi +source_debug "sourcing ~/.bash/rc" + # Load global env file for current hostname (first part before a dot) or # global env.local. source_config ~/.shell "" env $host @@ -28,3 +34,5 @@ set -o vi # Load rc file for current hostname (first part before a dot) or rc.local. source_config ~/.bash host rc $host + +source_debug "finished sourcing ~/.bash/env" diff --git a/shell/env b/shell/env index e30b272..c654613 100644 --- a/shell/env +++ b/shell/env @@ -12,6 +12,8 @@ function source_debug() { } +source_debug "sourcing ~/.shell/env" + # Use UTF-8 encoding in the terminal. LC_ALL=en_US.UTF-8 LANG=$LC_ALL @@ -112,5 +114,9 @@ function source_config() { elif [ -f $source_file_local -a x$5 != xnolocal ]; then source_debug "source_config(): sourcing $source_file_local" source $source_file_local + else + source_debug "source_config(): neither exists" fi } + +source_debug "finished sourcing ~/.shell/env" diff --git a/tests/source_config.test.out b/tests/source_config.test.out index dcadd7f..7e1cec7 100644 --- a/tests/source_config.test.out +++ b/tests/source_config.test.out @@ -13,12 +13,14 @@ source_config(): sourcing tmp/zsh/host/rc.zucker loaded zsh/host/rc.zucker source_config(): checking if tmp/zsh/os/env.Darwin exists source_config(): checking if tmp/zsh/env.local exists +source_config(): neither exists source_config(): checking if tmp/zsh/host/env.zucker exists source_config(): checking if tmp/zsh/env.local exists source_config(): sourcing tmp/zsh/env.local loaded zsh.env.local source_config(): checking if tmp/bash/host/rc.zucker exists source_config(): checking if tmp/bash/rc.local exists +source_config(): neither exists source_config(): checking if tmp/shell//env.zucker exists source_config(): checking if tmp/shell/env.local exists source_config(): sourcing tmp/shell//env.zucker diff --git a/zsh/env b/zsh/env index ade0f31..365c01b 100644 --- a/zsh/env +++ b/zsh/env @@ -7,12 +7,18 @@ host=${$(hostname)//.*/} # Load environmental related settings used by all shells. if [[ -f ~/.shell/env ]]; then source ~/.shell/env +# Fallback functions as ~/.shell/env couldn't be loaded. else + function source_debug() { + echo $@ + } function source_config() { echo "Couldn't load source_config(), can't source files." >&2 } fi +source_debug "sourcing ~/.zsh/env" + # Load global env file for current hostname (first part before a dot) or # global env.local. source_config ~/.shell "" env $host @@ -21,3 +27,5 @@ source_config ~/.shell "" env $host source_config ~/.zsh os env $(uname) nolocal # Load env file for current hostname (first part before a dot) or env.local. source_config ~/.zsh host env $host + +source_debug "finished sourcing ~/.zsh/env" diff --git a/zsh/rc b/zsh/rc index 69b19df..a7d62cc 100644 --- a/zsh/rc +++ b/zsh/rc @@ -1,6 +1,8 @@ # Zsh configuration file. +source_debug "sourcing ~/.zsh/rc" + # MISCELLANEOUS SETTINGS # Use Vi(m) style key bindings. @@ -296,3 +298,5 @@ todo() { source_config ~/.zsh os rc $(uname) nolocal # Load rc file for current hostname (first part before a dot) or rc.local. source_config ~/.zsh host rc ${$(hostname)//.*/} + +source_debug "finished sourcing ~/.zsh/rc" -- 2.44.1