From 9eb7e2a012a833109014654d93561c038a0b70c3 Mon Sep 17 00:00:00 2001 From: pztrn Date: Sat, 21 Mar 2015 20:30:55 +0500 Subject: [PATCH] Moar fixes to sourcerers. DEBUG variable force in config loader. If variable isn't defined - force it to be 0. --- zsh/01-config.zsh | 7 +++---- zsh/05-vars.zsh | 10 +++++++++- zsh/10-exports.zsh | 8 ++++---- zsh/50-aliases.zsh | 10 +++++----- zsh/lib/logger.lib.sh | 1 - 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/zsh/01-config.zsh b/zsh/01-config.zsh index 8802e0d..1fc2868 100644 --- a/zsh/01-config.zsh +++ b/zsh/01-config.zsh @@ -1,10 +1,9 @@ # Configuration file loader. - if [ ! -d ${HOME}/.zsh-config.d/ ]; then - cp -R ${CONFIG_PATH}/zsh/defaults/ ${HOME}/.zsh-config.d + cp -R "${CONFIG_PATH}/zsh/defaults/" ${HOME}/.zsh-config.d echo "Looks like it's a very first launch. So I've copied default config to '${HOME}/.zsh-config.d/'" fi -for file in `find ${HOME}/.zsh-config.d/ -type f -depth 1 | sort`; do - source ${file} +for file in `find ${HOME}/.zsh-config.d/ -maxdepth 1 -type f -exec basename {} \; | sort`; do + source "${HOME}/.zsh-config.d/${file}" done diff --git a/zsh/05-vars.zsh b/zsh/05-vars.zsh index a29afac..396d2b1 100644 --- a/zsh/05-vars.zsh +++ b/zsh/05-vars.zsh @@ -2,4 +2,12 @@ # this configuration. OS=`uname` -OS_RELEASE=`uname -r` \ No newline at end of file +OS_RELEASE=`uname -r` + +# Variable forcers. + +# If DEBUG isn't defined - force it to be 0. +if [ -z ${DEBUG} ]; then + DEBUG=0 + return 1 +fi diff --git a/zsh/10-exports.zsh b/zsh/10-exports.zsh index 4cbaf89..2974373 100644 --- a/zsh/10-exports.zsh +++ b/zsh/10-exports.zsh @@ -1,13 +1,13 @@ # Some default exports. They could be based on configuration variables. -for config_file in `find ${CONFIG_PATH}/zsh/exports -type f | sort`; do - source ${config_file} +for config_file in `find ${CONFIG_PATH}/zsh/exports -type f -exec basename {} \; | sort`; do + source "${CONFIG_PATH}/zsh/exports/${config_file}" done # We should import user-specific exports and use them. if [ -d ${HOME}/.zsh-config.d/exports ]; then - for config_file in `find ${HOME}/.zsh-config.d/exports -type f | sort`; do + for config_file in `find ${HOME}/.zsh-config.d/exports -type f -exec basename {} \; | sort`; do if [ -f ${config_file} ]; then - source ${config_file} + source "${HOME}/.zsh-config.d/exports/${config_file}" fi done fi diff --git a/zsh/50-aliases.zsh b/zsh/50-aliases.zsh index 41db520..1ebe77a 100644 --- a/zsh/50-aliases.zsh +++ b/zsh/50-aliases.zsh @@ -7,14 +7,14 @@ alias screen="TERM=xterm screen" alias clocksync="sudo ntpdate 0.pool.ntp.org" alias got="git" -for item in `find ${CONFIG_PATH}/zsh/aliases -type f | sort`; do - source ${item} +for item in `find "${CONFIG_PATH}/zsh/aliases" -type f -exec basename {} \; | sort`; do + source "${CONFIG_PATH}/zsh/aliases/${item}" done if [ -d "${HOME}/.zsh-config.d/aliases" ]; then - for item in `find ${HOME}/.zsh-config.d/aliases -type f | sort`; do - if [ -f ${item} ]; then - source ${item} + for item in `find "${HOME}/.zsh-config.d/aliases" -type f -exec basename {} \; | sort`; do + if [ -f "${HOME}/.zsh-config.d/aliases/${item}" ]; then + source "${HOME}/.zsh-config.d/aliases/${item}" fi done fi diff --git a/zsh/lib/logger.lib.sh b/zsh/lib/logger.lib.sh index 2b08025..efc74df 100644 --- a/zsh/lib/logger.lib.sh +++ b/zsh/lib/logger.lib.sh @@ -63,7 +63,6 @@ function check_debug() { # - 1: this debug level should not be printed. local DEBUG_LVL=$1 - if [ ${DEBUG_LVL} -le ${DEBUG} ]; then return 0 else