How to suppress the output of a function, receiving a return code?

Good time of day.

Have a custom function in bash form:
superMegaFunction()
{
.................
 echo "FATAL ERROR: some_text_error"
 return 127
.................
 return 0
}


Further in the code, you need to get the return code of the function above, i.e. 0 or 127, while suppressing any output like echo. Try to do this:
checkMega()
{
 superMegaFunction &> /dev/null
 echo "Status: $?"
}

Executing the script to echo even comes, i.e. when the flag is set, bash -x , I do not see the output "Status: %code%". Tried the version without superMegaFunction > /dev/null - the result is the same

Please tell me, what am I doing wrong? When you return to the bash after all, must in any case return code, while still running the overall script or something I should consider?
July 8th 19 at 12:23
1 answer
July 8th 19 at 12:25
Solution
all perfectly worked through, for example:
f(){
 if [[ $1 != "" ]]
 then echo "ok"
 return 0
 else echo "error"
 return 1
fi
}

check_f(){
 f &> /dev/null
 echo "Status: $?"

 f ww &> /dev/null
 echo "Status: $?"
}

check_f

the output will be:
Status: 1
Status: 0


you see something in the function superMegaFunction messed up, maybe there somewhere is exit
Thank You. Your answer led me to an idea which was correct. - merl_Ja commented on July 8th 19 at 12:28

Find more questions by tags bashLinux