[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: xtrace output on new file descriptor
From: |
Marc Herbert |
Subject: |
Re: xtrace output on new file descriptor |
Date: |
Fri, 11 Dec 2009 09:40:14 +0000 |
User-agent: |
Thunderbird 2.0.0.21 (X11/20090320) |
Brian J. Murrell a écrit :
> Is equally difficult?
Do you mean "equally difficult" as in "impossible"? Then I would say no,
it looks easier :-)
> Or can I more easily play with FD duplication and redirection to
> achieve that, even if it means adding a ">&word" at the end of things
> I want on the real stdout?
I guess the answer is yes. You cannot redirect the output of "set -x",
but you can redirect your own outputs.
# Duplicate a descriptor to stdout to escape redirections, like for
# instance in command substitution.
exec 3>&1; PRESERVED_STDOUT=3
foo()
{
{
echo "this is a message the user should see on stdout"
} >&${PRESERVED_STDOUT}
echo "this is the function return value"
}
bar=$(foo)
echo "bar==$bar"