diff --git a/hooks/_init.sh b/hooks/_init.sh index 1e773d0..1d8ac44 100755 --- a/hooks/_init.sh +++ b/hooks/_init.sh @@ -6,24 +6,33 @@ HOOK_PATH=${HOOK_PATH%/*} export HOOK_PATH -err_trap() { - echo "Error: $BASH_COMMAND" -} - if [[ $PINCH_DEBUG -eq 1 ]]; then pdebug() { echo -e "\033[33m(DEBUG)\033[0m $@" } -else +else pdebug() { : } fi pinfo() { - echo -e "\033[32m=>\033[0m $@" + echo -e "\033[1;32m=>\033[0m $@" } +pwarn() { + echo -e "\033[1;33m(warning) =>\033[0m $@" +} + +perror() { + echo -e "\033[1;31m(error) =>\033[0m $@" +} + +err_trap() { + perror "Error during execution of $EXEC_NAME." +} + +export -f pinfo pwarn perror export -f pdebug export -f err_trap @@ -35,6 +44,7 @@ exec_custom() { for hook in $(ls $hooks_path); do if [ -x $hooks_path/$hook ]; then pdebug "Executing custom hook $hooks_path/$hook" + export EXEC_NAME="custom::$(basename $0)::$hook" $hooks_path/$hook $HOOK_ARGS fi done @@ -44,6 +54,7 @@ exec_all() { for file in $(ls $1 | sort); do if [ -x $1/$file ]; then pdebug "Executing hook $1/$file" + export EXEC_NAME="$(basename $0)::$file" $1/$file $HOOK_ARGS fi done