? Expands to the exit status of the most recently executed foreground pipeline. $ foo="$(echo foobar ; exit 3)" ; ret=$? ; echo "output: $foo" ; echo "return status: $ret" output: foobar return status: 3