Well the usual story, when you place set -xv at the start of your script, what do you notice is (is not) happening?
But the answer to your question is the difference between a return / exit value (ie was the command successful or not) and does the command send any output back from being called.
Example:
Code:
$ ls *.txt
file.txt
$ echo $?
0
$ x=$(ls *.txt)
$ echo $?
0
$ echo $x
file.txt
In your case, if you issue the 'echo $?' after you call _menu, you will get the numbers you were expecting, but as none of your command send any data back, as most is redirected, then your variable
is quite correctly empty.