I'd like to run two commands in bash, and afterwards if either of them failed, quit my script. I've got the following which does exactly that:
echo "Linking ${bold}Linux PTB${normal} ${PTB_VERSION}..."
dblsqd push -a mudlet -c public-test-build -r "${PTB_VERSION}" -s mudlet --type "standalone" --attach linux:x86_64 "${LINUX_PTB_URL}" || EXIT_CODE_LINUX=$?
echo "Linking ${bold}macOS PTB${normal} ${PTB_VERSION}..."
dblsqd push -a mudlet -c public-test-build -r "${PTB_VERSION}" -s mudlet --type "standalone" --attach mac:x86_64 "${MACOS_PTB_URL}" || EXIT_CODE_MACOS=$?
if [ "${EXIT_CODE_LINUX}" != 0 ] && [ "${EXIT_CODE_MACOS}" != 0 ]; then
exit 1
fi
This works great. Now, I'd like my exit condition to take into account the output of stdout and stderr - if it contains exists already for this release, then do not consider the exit code in this case.
I've tried doing this:
EXIT_CODE_LINUX=0
LINUX_OUTPUT=$(mktemp)
EXIT_CODE_MACOS=0
MACOS_OUTPUT=$(mktemp)
echo "Linking ${bold}Linux PTB${normal} ${PTB_VERSION}..."
dblsqd push -a mudlet -c public-test-build -r "${PTB_VERSION}" -s mudlet --type "standalone" --attach linux:x86_64 "${LINUX_PTB_URL}" 1>$LINUX_OUTPUT || EXIT_CODE_LINUX=$?
echo "Linking ${bold}macOS PTB${normal} ${PTB_VERSION}..."
dblsqd push -a mudlet -c public-test-build -r "${PTB_VERSION}" -s mudlet --type "standalone" --attach mac:x86_64 "${MACOS_PTB_URL}" 1>$MACOS_OUTPUT || EXIT_CODE_MACOS=$?
[ -z "$EXIT_CODE_LINUX" ] || [ "$LINUX_OUTPUT" != *"This combination of os:arch and type exists already for this release."* ] && exit 1
[ -z "$EXIT_CODE_MACOS" ] || [ "$MACOS_OUTPUT" != *"This combination of os:arch and type exists already for this release."* ] && exit 1
But that just made it ignore all exit codes. What is the right approach here?