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 |