I'd like to do:
#!/usr/bin/env bash set -eu r=0 a=$(./2.sh || r=$?) echo "$a" echo "$r"
#!/usr/bin/env bash echo output exit 2
But it outputs:
$ ./1.sh output 0 # I'd like to have `2` here
$(...) runs a separate shell. So, how do I capture both, exit code and output?