summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2010-10-24 09:41:33 +0200
committerZac Medico <zmedico@gentoo.org>2010-10-24 11:34:12 -0700
commitf01c11eb38b25512e769f2e2da68cb369a8b7a09 (patch)
tree41bef2af849be0527427fed4eaf86bc2f0e73bef
parent83525c3837ff34614370bf3a18dbb53083404eb2 (diff)
downloadportage-f01c11eb38b25512e769f2e2da68cb369a8b7a09.tar.gz
portage-f01c11eb38b25512e769f2e2da68cb369a8b7a09.tar.bz2
portage-f01c11eb38b25512e769f2e2da68cb369a8b7a09.zip
Simplify debug-print*() functions code.
Make debug-print() and friends a lot simpler. Thanks to Mike Frysinger for his suggestions.
-rwxr-xr-xbin/ebuild.sh32
1 files 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