Michael Johansen
Michael Johansen

Reputation: 1447

In bash, how to make "set -x" print lines to stdout instead of stderr?

I would like a trace for each command after it expands the command and before it executes it, just like what set -x does, but I do not want it to be printed do stderr.

I know I could redirect stderr to stdout, like exec 2>&1, but that will redirect all of stderr (and exec would be printed to stderr). I still want actual error messages to be printed to stderr, so redirecting everything is not what I want.

Upvotes: 3

Views: 712

Answers (1)

KamilCuk
KamilCuk

Reputation: 141155

Set BASH_XTRACEFD.

BASH_XTRACEFD=1

Upvotes: 10

Related Questions