I know that subshells have their stdout suppressed from the caller's output:
a=$(echo 123)
echo a:$a
This outputs, as expected:
a:123
But why isn't stderr suppressed as it's in a subshell?
a=$(>&2 echo 123)
Expected output:
(nothing)
Actual output:
123
Here is a test where stderr should redirect to stdout and be captured to variable a
:
a=$(>&2 echo 123 2>&1)
echo a:$a
Expected output:
a:123
Actual output:
123
a: