#!/bin/bash
RET=0
export RET
{
ssh -q -t user@host <<EOF
echo "hello there "
exit 10
EOF
RET=$?
echo "Out is" $RET
} &
echo "RET is $RET"
################## End
I get RET 0 OUT is 10
How can I get correct exit status code in outer block. I need to see exit code 10.
&. It is running the first part in background.