I've got a working global_exit i copied from somewhere, it's for two command exits. Renaming 'echo' to 'ech' to force a failure allows me to test all the permutations work - and they do here:
echo "$USER $(date +%F)" |& tee info.log
info_exit=${PIPESTATUS[0]}
echo "$USER $(date +%F)" |& tee list.log
list_exit=${PIPESTATUS[0]}
global_exit=$(( info_exit > list_exit ? info_exit : list_exit ))
if [ ${global_exit} = "0" ]; then
echo ">> SUCCESS <<"
elif [ ${global_exit} = "1" ]; then
echo ">> WARNINGS <<"
else
echo ">> FAILED <<"
fi
exit
How can i expand that to three RCs? I haven't been able to find the rules around how to use this feature. I just guessed using the below, but it doesn't work across all permutations of the same test (one-by-one rename just one echo to ech to force a failure):
echo "$USER $(date +%F)" |& tee info.log
info_exit=${PIPESTATUS[0]}
echo "$USER $(date +%F)" |& tee list.log
list_exit=${PIPESTATUS[0]}
echo "$USER $(date +%F)" |& tee check.log
check_exit=${PIPESTATUS[0]}
global_exit=$((( info_exit > list_exit > check_exit ? info_exit : list_exit > check_exit )))
if [ ${global_exit} = "0" ]; then
echo ">> SUCCESS <<"
elif [ ${global_exit} = "1" ]; then
echo ">> WARNINGS <<"
else
echo ">> FAILED <<"
fi
exit
Thanks :)