Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o, "Michał Górny" <mgorny@g.o>
Cc: 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:28:59
Message-Id: 544C0806.4070704@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:25 PM, Micha³ Górny wrote:
2 > Dnia 2014-10-25, o godz. 12:42:14
3 > Zac Medico <zmedico@g.o> napisa³(a):
4 >
5 >> On 10/25/2014 09:15 AM, Michael Palimaka wrote:
6 >>> +eqalog() {
7 >>> + local tag=$1 x
8 >>> + shift
9 >>> + for x in "$@" ; do
10 >>> + echo "${tag}" "${x}" >> "${T}"/qa.log
11 >>> + done
12 >>> +}
13 >>
14 >> Your patches look good to me, except that I think eqalog should escape
15 >> any \n characters that might be embedded in the arguments.
16 >
17 > Why? That sounds like some unsafe fancy feature only one person would
18 > use. Embedding newlines in bash is trivial, why make them implicit with
19 > a lot of added complexity?
20
21 Because the caller should not be concerned about the qa.log file format.
22 The fact that it's delimited by newlines is an implementation detail
23 that the caller need know nothing about. Escaping the new lines is
24 really not all that complex. All of the elog functions have similar
25 handling for newlines.
26 --
27 Thanks,
28 Zac

Replies