This looks very useful to me. I guess SUS doesn't specify this? > For this, stderr is remembered only when tracing turns from off to on, > if it is on already, and another "set -x" is performed, nothing changes. I can't unambigiously parse that. On second reading, treating the comma at the end of the first line more as a semicolon or full stop, I stumble over what "nothing changes" means: The shell treats this as a no-op or the shell behaves as without your change? From further reading, I guess it's a no-op.
> And yes, if tracing is off, "set -x 2>/tmp/trace-file" works as expected This is brilliant!