Hi Greg,
Keeping you CC'd.
context: the problem is there are (typically) multiple "Received:"
header in an e-mail messages; can try either of these
----
bash% fmttest -outsize max +SOMEFOLDER 660 -format "%(putstr{received});"
bash% fmttest -outsize max +SOMEFOLDER 660 -format "%(putlit{received});"
----
and get either a long line, or a number of lines, but without any real
indication of how to separate the output into individual "Received"
lines.
Here's my input test file.
$ sed -n l mail
foo: a aa$
foo: b bb$
foo: c$
cc$
foo:$
dd$
foo: e$
\tee$
$
Obvious approach, as you found, gives all the values of the Received
fields in one go.
$ fmttest -outsize max -format '%{foo}' -file mail
a aa b bb c cc dd e ee
$
-dump and -trace can be useful for more insight.
$ fmttest -dump -trace -outsize max -format '%{foo}' -file mail
Instruction dump of format string:
%{foo}
COMP, comp "foo"
DONE
COMP, comp "foo", c_flags 0x8<TRIMMED>
num=0 str=<nil>
outbuf="a aa b bb c cc dd e ee"
DONE
a aa b bb c cc dd e ee
$
Using %(putstr) shows the string register being set to the values with a
tab inserted to join them together.
$ fmttest -dump -trace -outsize max -format '%(putstr{foo})' -file mail
Instruction dump of format string:
%(putstr{foo})
LS_COMP, comp "foo"
STR
DONE
LS_COMP, comp "foo", c_flags 0x8<TRIMMED>
num=0 str=" a aa\n\t b bb\n\t c\n cc\n\t\n dd\n\t e\n\tee"
STR
outbuf="a aa b bb c cc dd e ee"
DONE
a aa b bb c cc dd e ee
$
Using %(putlit) preserves those tabs.
$ fmttest -dump -trace -outsize max -format '%(putlit{foo})' -file mail
Instruction dump of format string:
%(putlit{foo})
LS_COMP, comp "foo"
STRLIT
DONE
LS_COMP, comp "foo", c_flags 0x8<TRIMMED>
num=0 str=" a aa\n\t b bb\n\t c\n cc\n\t\n dd\n\t e\n\tee"
STRLIT
outbuf=" a aa\n\t b bb\n\t c\n cc\n\t\n dd\n\t e\n\tee"
DONE
a aa
b bb
c
cc
dd
e
ee
$
But \n\t can't be used to split them back into the original distinct
field values because that may occur within a value, as with my ee test
input.
That's all I've time for at the moment, but others may chip in and this
saves them covering some of the ground.
--
Cheers, Ralph.