Send stderr to variable, but send stdout to screen?
I have an error handling function that traps, reports and exits on an error.
My problem is that I want to do all of that and I want to still see stdout.
Can anyone help with this? Here is the function. If I change sources.list to
have an invalid source it reports, but I do not see the progress when there
is no error.
# R1040 error handling
# Don't abort on errors
# Capture STDERR to ERR
# Capture return value from command
# re-enable abort-on-errors
echo "********** ERROR DETECTED in $CMD **********" | tee -a
echo "********** Error reported was \"$ERR\"" | tee -a
echo "Exiting script abnormally. The error above was
reported in log at $logfile"
trap errhandler ERR
run 'apt-get update'
# should not get past this on error