Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: "Michał Górny" <mgorny@g.o>
Cc: gentoo-portage-dev@l.g.o, Michael Palimaka <kensington@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH 1/3] bin/misc-functions.sh: Introduce eqalog and eqawarnlog functions.
Date: Sat, 25 Oct 2014 20:53:31
Message-Id: 544C0DC4.6080504@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH 1/3] bin/misc-functions.sh: Introduce eqalog and eqawarnlog functions. by "Michał Górny"
1 On 10/25/2014 01:41 PM, Micha³ Górny wrote:
2 > Dnia 2014-10-25, o godz. 13:28:54
3 > Zac Medico <zmedico@g.o> napisa³(a):
4 >
5 >> On 10/25/2014 01:25 PM, Micha³ Górny wrote:
6 >>> Dnia 2014-10-25, o godz. 12:42:14
7 >>> Zac Medico <zmedico@g.o> napisa³(a):
8 >>>
9 >>>> On 10/25/2014 09:15 AM, Michael Palimaka wrote:
10 >>>>> +eqalog() {
11 >>>>> + local tag=$1 x
12 >>>>> + shift
13 >>>>> + for x in "$@" ; do
14 >>>>> + echo "${tag}" "${x}" >> "${T}"/qa.log
15 >>>>> + done
16 >>>>> +}
17 >>>>
18 >>>> Your patches look good to me, except that I think eqalog should escape
19 >>>> any \n characters that might be embedded in the arguments.
20 >>>
21 >>> Why? That sounds like some unsafe fancy feature only one person would
22 >>> use. Embedding newlines in bash is trivial, why make them implicit with
23 >>> a lot of added complexity?
24 >>
25 >> Because the caller should not be concerned about the qa.log file format.
26 >> The fact that it's delimited by newlines is an implementation detail
27 >> that the caller need know nothing about. Escaping the new lines is
28 >> really not all that complex. All of the elog functions have similar
29 >> handling for newlines.
30 >
31 > Oh, you mean converting from newlines to \n escapes? I thought
32 > the opposite way, sorry then.
33
34 Right, that's what my sample code does.
35 --
36 Thanks,
37 Zac