From 6d41d0a4646b226d73b6dbe713542d28071515dc Mon Sep 17 00:00:00 2001 From: Bernhard Landauer Date: Mon, 6 Mar 2017 00:26:55 +0100 Subject: [PATCH] add debug option -d --- bin/manjaro-architect.in | 3 +++ lib/util.sh | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/manjaro-architect.in b/bin/manjaro-architect.in index c079f8c..085ed72 100644 --- a/bin/manjaro-architect.in +++ b/bin/manjaro-architect.in @@ -24,6 +24,9 @@ import ${LIBDIR}/util-disk.sh [[ ! -e ~/.dialogrc ]] && [[ -e /etc/skel/.dialogrc ]] && cp /etc/skel/.dialogrc ~/.dialogrc +# run in debug mode with -d option +[[ $1 == "-d" ]] && declare -i debug=1 + id_system select_language mk_connection diff --git a/lib/util.sh b/lib/util.sh index d37f7ab..ceca0c1 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -164,15 +164,17 @@ check_for_error() { # and function varsdump ? _msg="$_msg \n $(declare -p | grep -v " _")" local _fpath="${FUNCNAME[*]:1:2}()" _fpath=" --${_fpath// /()<-}" - echo -e "$(date +%D\ %T) ERROR ${_msg} ${_fpath}" >> "${LOGFILE}" + ! ((debug)) && _fpath="" + echo -e "$(date +%D\ %T) ERROR ${_msg}${_fpath}" >> "${LOGFILE}" if [[ "${_function_menu}" != "SKIP" ]]; then DIALOG " $_ErrTitle " --msgbox "\n${_msg}\n" 0 0 # return error for return to parent menu return $_err - fi + fi else # add $FUNCNAME limit to 20 max for control if recursive - echo -e "$(date +%D\ %T) ${_msg} --${FUNCNAME[*]:1:20}" >> "${LOGFILE}" + ((debug)) && _msg="${_msg} --${FUNCNAME[*]:1:20}" + echo -e "$(date +%D\ %T) ${_msg}" >> "${LOGFILE}" fi }