I have a C shell that usually calls Tcl routines using Tcl_Eval. Normally I was fine with just executing what the user typed and getting some status as a result. However, no
I think you could go like this:
Then in your interp:
stdout by calling Tcl_Close() on it.stdout channel by calling Tcl_MakeChannel() right after closing stdout.Or use just replace the stdout with a call to Tcl_SetStdChannel().
As to your side note — I think you could just call Tcl_Eval() in your interpreter and process the returned list using the list-processing functions from the Tcl API.
Update (from one of my comments): after some more thought I think it might be possible to just create a custom Tcl channel which implementation would just save away the data written to it and then register an instance of such a channel as stdout. See Tcl_CreateChannel() and Tcl_RegisterChannel().