Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.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 19:42:20
Message-Id: 544BFD16.8040501@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 1/3] bin/misc-functions.sh: Introduce eqalog and eqawarnlog functions. by Michael Palimaka
1 On 10/25/2014 09:15 AM, Michael Palimaka wrote:
2 > +eqalog() {
3 > + local tag=$1 x
4 > + shift
5 > + for x in "$@" ; do
6 > + echo "${tag}" "${x}" >> "${T}"/qa.log
7 > + done
8 > +}
9
10 Your patches look good to me, except that I think eqalog should escape
11 any \n characters that might be embedded in the arguments.
12
13 We might use something like this to escape all but the last \n character:
14
15 echo "${tag}" "${x}"| (escape="" ; while read -r ; do echo -n "${escape}${REPLY}" ; escape="\\n"; done ; echo ) >> "${T}"/qa.log
16
17 Here's a test case showing that it works:
18
19 $ echo -e "foo\nbar\nbaz"| (escape="" ; while read -r ; do echo -n "${escape}${REPLY}" ; escape="\\n"; done ; echo )
20 foo\nbar\nbaz
21 --
22 Thanks,
23 Zac

Replies