Given the following contrived example which intent is to only erase the subcommand's /dev/tty
:
result="$(
tput smcup > /dev/tty
tput cup 0 0 > /dev/tty
echo 'meh' > /dev/tty
echo 'nay' > /dev/stderr
echo 'yay' > /dev/stdout
tput rmcup > /dev/tty
)"; echo "result=[$result]"
It outputs:
result=[yay]
However, the stderr of nay
is no longer kept in the display. How can I make sure that stderr is kept displayed? Such that the output is:
nay
result=[yay]
The real use case is where the subcommand asks the user a series of questions and calculates a response that is sent to stdout, and if an error occurs the error is sent to stderr. Once the subcommand is completed the intent is for the question interaction to be wiped, the stdout to be stored, and any stderr to be displayed.