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

Good time of day.

Have a custom function in bash form:
 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:
 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
all perfectly worked through, for example:
 if [[ $1 != "" ]]
 then echo "ok"
 return 0
 else echo "error"
 return 1

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

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


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