Improving xtrace output from subshells
Quoted 10 lines · Harald van Dijk
Quoted 7 lines · Vadim Zeitlin
On Sat, 27 Apr 2019 22:58:23 +0100 Harald van Dijk <[email protected]> wrote:
HvD> It wastes memory: the code should be re-worked so that output and HvD> preverrout share the same buffer, given that there can never be pending HvD> output for one when the other is being written to.I'm a bit worried about this one, it doesn't seem completely obvious to me that the 2 objects can't be used at the same time.
It's indeed not completely obvious, but all bits that print to output will flush the buffer when they're done, before a next command starts executing, before the next command requires an xtrace string to be printed. It's usually the
flushall()inevalbltin()that handles this.
I have managed to verify that using a single buffer for all streams (output, errout and preverrout) works well and simplifies logic so that the shell with that change is actually smaller than the one without it. I do not know whether there would be interest in getting that in dash.
Cheers,
Harald van Dijk