On Wednesday, 1 February 2017 at 01:08:19 UTC, Emil wrote:
is it possible to intercept the STDOUT or STDERR and capture
the output into a variable ?
some pseudocode to explain what I mean
string[] output_buffer;
stdout.capture_to(output_buffer);
writeln("test 1"); # not printed
writeln("test 2"); # not printed
stdout.release(output_buffer);
writeln("test 3"); # printed
writeln(output_buffer); # prints '["test 1","test 2"]'
If you *had* to, you should be able to hack it by reopening the
file descriptors for standard output or error (at least on *nix),
but is there a specific reason you want to do this, or do you
just want formatted output to a variable?