I need to check which of the condition failed. Is there a better way of doing this? How can I refactor the code with less lines of code? Maybe a one liner if/else condition?
flag1=0
flag2=0
flag3=0
flag4=0
success=0
FAIL=""
if (( 2==2 ))
then
flag1=1
fi
# check if anything is 0
if (( $flag1==1 ))
then
FAIL="flag1"
elif (( $flag2==1 ))
then
FAIL="flag2"
elif (( $flag3==1 ))
then
FAIL="flag3"
elif (( $flag4==1 ))
then
FAIL="flag4"
fi;
echo failed is $FAIL