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"