6

I know that I can redirect the xtrace output to some_file with something like this:

exec 2 >> some_file
set +x

...but this sends to some_file not only the xtrace output, but also any other content originally sent to fd 2, which includes most error messages and warnings, all unrelated to xtrace.

Is there a way to capture only the xtrace output in some_file?

I should add that I'm looking for a way to do this that would distort as little as possible the xtrace output itself, and the timing information gathered through a PS4 setting like, e.g.

zmodload zsh/datetime
export PS4='${(j::)epochtime} %N:%i> '
  • 3
    Looking at the source code, this doesn't appear to be possible: traces are written to xtrerr and xtrerr is initialized with xtrerr = stderr and changes only temporarily while processing a redirection. – Gilles Jan 12 '17 at 1:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.