Re: How does TCL (internals) generate output to stdout



On Jan 20, 10:31 pm, sam appleton <sam.s.apple...@xxxxxxxxx> wrote:
Hi

(TCL version 8.5.8)

I would like to understand how TCL generates output to stdout, for
example,
when I type at the tclsh prompt,

% set x 1
1
% set x
1
%

how does this output get generated? I traced the behavior of
Tcl_PutsObjCmd (tclIOCmd.c),
which calls Tcl_WriteObj (tclIO.c) which then calls Tcl_WriteChars,
which then calls DoWriteChars.
How does the above command sequence get captured and printed to
stdout?

I am trying to intercept the write function at some point with a patch
that allows me to log the output.
(externally wrapping functions like tee -a are not acceptable in the
environment our software goes into).

Sam

You can try script(1) if you are using Unix. The problem is that it
captures the terminal's control escapes.

pmarin
.