Reputation: 2406
I have a subshell carrying out a function:
local thing=$( doFunc )
doFunc
sends logging output to stderr
(2) and 'thing
' gets assigned to doFunc
's output on stdout
(1).
How can I run this line, but print stderr
from the subshell to stdout
in the current shell?
Upvotes: 3
Views: 1477
Reputation: 14500
You can first make a copy of stdout on another FD, then redirect to that like
exec 3>&1
local thing=$(doFunc 2>&3)
Upvotes: 10