Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: Mike Frysinger <vapier@g.o>
Cc: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions
Date: Sun, 10 Oct 2010 07:38:26
Message-Id: 20101010093647.485bc781@pomiocik.lan
In Reply to: Re: [gentoo-dev] eclass/tests/tests-common.sh: debug-print family of functions by Mike Frysinger
1 On Sat, 9 Oct 2010 17:33:41 -0400
2 Mike Frysinger <vapier@g.o> wrote:
3
4 > On Saturday, October 09, 2010 11:16:38 Michał Górny wrote:
5 > > +debug-print() {
6 > > + while [[ ${1} ]]; do
7 >
8 > use explicit -n here, although this could give incorrect behavior.
9 > better to use [[ $# -gt 0 ]].
10
11 True.
12
13 > > + if [[ ${ECLASS_DEBUG_OUTPUT} = on ]]; then
14 >
15 > if you're going to use [[]], then also use ==
16
17 Pointless. == implies pattern matching.
18
19 > > + echo "debug: ${1}" >&2
20 > > + elif [[ -n ${ECLASS_DEBUG_OUTPUT} ]]; then
21 > > + echo "debug: ${1}" >>
22 > > "${ECLASS_DEBUG_OUTPUT}"
23 > > + fi
24 >
25 > this whole func is overkill. just use a single printf:
26
27 I agree but I assumed Portage behavior has some reason for it. Maybe
28 it's some kind of pseudo-multiline output?
29
30 debug-print 'line1' \
31 'line2'
32
33 where each line would be prefixed with 'debug:'.
34
35 > > +debug-print-function() {
36 > > + local f="${1}: entering function"
37 > > + shift
38 > > + debug-print "${f}, parameters: ${*}"
39 > > +}
40 >
41 > debug-print ${1}: entering function, parameters: ${*:2}"
42
43 Ok.
44
45 --
46 Best regards,
47 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies