From f01c11eb38b25512e769f2e2da68cb369a8b7a09 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 24 Oct 2010 09:41:33 +0200 Subject: [PATCH] Simplify debug-print*() functions code. Make debug-print() and friends a lot simpler. Thanks to Mike Frysinger for his suggestions. --- bin/ebuild.sh | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 2036094e3..c7f81c50e 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1273,36 +1273,28 @@ dyn_help() { debug-print() { # if $T isn't defined, we're in dep calculation mode and # shouldn't do anything - [ ! -d "$T" ] && return 0 + [[ ! -d ${T} || ${#} -eq 0 ]] && return 0 - while [ "$1" ]; do - - # extra user-configurable targets - if [ "$ECLASS_DEBUG_OUTPUT" == "on" ]; then - echo "debug: $1" >&2 - elif [ -n "$ECLASS_DEBUG_OUTPUT" ]; then - echo "debug: $1" >> $ECLASS_DEBUG_OUTPUT - fi - - # default target - echo "$1" 2>/dev/null >> "${T}/eclass-debug.log" - # let the portage user own/write to this file - chmod g+w "${T}/eclass-debug.log" &>/dev/null + if [[ ${ECLASS_DEBUG_OUTPUT} == on ]]; then + printf 'debug: %s\n' "${@}" >&2 + elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]]; then + printf 'debug: %s\n' "${@}" >> "${ECLASS_DEBUG_OUTPUT}" + fi - shift - done + # default target + printf '%s\n' "${@}" >> "${T}/eclass-debug.log" + # let the portage user own/write to this file + chmod g+w "${T}/eclass-debug.log" &>/dev/null } # The following 2 functions are debug-print() wrappers debug-print-function() { - str="$1: entering function" - shift - debug-print "$str, parameters: $*" + debug-print "${1}, parameters: ${*:2}" } debug-print-section() { - debug-print "now in section $*" + debug-print "now in section ${*}" } # Sources all eclasses in parameters -- 2.26.2