Handle return codes in bash scripts

echo “Fireanote: Creating directory $directory
cmd_mk_dir=“mkdir -p $directory
ssh $ssh_key $server $cmd_mk_dir
rc=$?
if [[ $rc != 0 ]]
then
exit $rc
fi
 
Reference
https://stackoverflow.com/questions/90418/exit-shell-script-based-on-process-exit-code