bash: redirect stdout and stder to _different_ variables

bash: redirect stdout and stder to _different_ variables

am 30.10.2007 20:59:44 von Nathan Collins

Is it possible to redirect stdout and stderr to different variables in
bash? I do things like

error_file=$(mktemp)
out=$( 2>$error_file)
err=$(< error_file)
rm $error_file

to get stdout in out and stderr in err when running , but I'd
like to avoid the temp file if possible.

Thanks,

-nathan