A classical example of piping:
$ false | true
$ echo ${PIPESTATUS[@]}
1 0
Same example run in a subshell and assigning results into a variable:
$ process="$(false | true)"
$ echo ${PIPESTATUS[@]}
0
How could I get the exit status of each of the piped processes?
Similar question, without the subshell part:
process="$(false | true ; echo ${PIPESTATUS[@]} >&2)"orprocess="$(false | true ; echo ${PIPESTATUS[@]} >/dev/tty)"echo ${PIPESTATUS}inside the command substitution subshell ;-) I guess your question is more about how to capture output other than stdout from a command substitution.t=$(mktemp); exec 3>$t 4<$t; rm "$t"; out=$(false | true | false | echo hmm; echo -n "${PIPESTATUS[@]}" >&3); readarray -td' ' st <&4; exec 3>&- 4<&-; echo "out=$out; st=(${st[*]})". Related: Redirect STDERR and STDOUT to different variables without temporary files${PIPESTATUS[@]}inecho "${PIPESTATUS[@]}", but you don't have to quote the$(...)inprocess=$(false | true).