Hi Bert, and thanks for persiting on this. On Friday 17 June 2011, Bert Wesarg wrote: > On Thu, Jun 16, 2011 at 22:00, Ralf Wildenhues <ralf.wildenh...@gmx.de> wrote: > > Hello, > > > > * Bert Wesarg wrote on Thu, Jun 16, 2011 at 08:19:23PM CEST: > >> the parallel part is a little trickier. Because the line printing is > >> done by awk. I would like to know, whether it is portable to use the > >> printf function of awk. It is POSIX, but you may know that this > >> doesn't count much. > > > > True. In case of doubt, try Solaris awk, that's fairly old. > > I don't have access to a solaris system. > > > > >> I couldn't find any prior usage in automake and > >> autoconf either. Nor does the autoconf manual list printf as a > >> functions in the traditional awk. > > > > Then I would prefer to do without. I don't see why you would need it > > for your change at all, however. All the coloring is done from echo > > statements even in the parallel case, and you can put the resets in > > there as well, methinks. > > The parallel code uses an awk script (am__text_box) to generate the > test report. Below is my current attempt with the help of awk's > printf. > > Bert > > diff --git c/lib/am/check.am i/lib/am/check.am > index 97ecb68..517e1ff 100644 lib/am/check.am > --- c/lib/am/check.am > +++ i/lib/am/check.am > @@ -75,15 +75,17 @@ am__rst_title = sed 's/.*/ & > /;h;s/./=/g;p;x;p;g;p;s/.*//' > am__rst_section = sed 'p;s/./=/g;p;g' > > # Put stdin (possibly several lines separated by ". ") in a box. > -am__text_box = $(AWK) '{ \ > - n = split($$0, lines, "\\. "); max = 0; \ > - for (i = 1; i <= n; ++i) \ > - if (max < length(lines[i])) \ > - max = length(lines[i]); \ > - for (i = 0; i < max; ++i) line = line "="; \ > - print line; \ > - for (i = 1; i <= n; ++i) if (lines[i]) print lines[i];\ > - print line; \ > +am__text_box = $(AWK) '{ \ > + n = split($$0, lines, "\\. "); max = 0; \ > + for (i = 1; i <= n; ++i) \ > + if (max < length(lines[i])) \ > + max = length(lines[i]); \ > + for (i = 0; i < max; ++i) line = line "="; \ > + printf("%s%s%s\n", col, line, std); \ > + for (i = 1; i <= n; ++i) \ > + if (lines[i]) \ > + printf("%s%s%s\n", col, lines[i], std); \ > + printf("%s%s%s\n", col, line, std); \ > }' > You could avoid the use of printf above by using the "automatic concatenation" feature of awk: $ echo x y | awk '{print $1 s $2}' s=":" $ x:y And now try this (the various "^[" represent the escape character): $ red='^[[0;31m' grn='^[[0;32m' std='^[[m' $ echo aaa bbb ccc | awk '{print red $1 grn $2 std $3 }' red="$red" grn="$grn" std="$std" Works as a charm also with Solaris 10 /bin/sh and /bin/awk, and with NetBSD 5.1 /bin/sh and /usr/bin/awk :-)
HTH, Stefano