How to retrieve "case "statement return value ?

How do we retrieve case statement return value at point indicated in the attached snippet


      case "$FUN" in
          1\ *) do_change_pass ;;
          2\ *) do_network_menu ;;
          3\ *) do_boot_menu ;;
          4\ *) do_internationalisation_menu ;;
          5\ *) do_ssh ;;
          6\ *) do_pixdub ;;
          8\ *) do_update ;;
          9\ *) do_about ;;
          *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 $
        esac || 

GET CASE RETURN VALUE HERE 

whiptail --msgbox "There was an error running option $FUN" 20 6$
      fi


Thanks

Can you elaborate on return statement from case ?

Do you wish to catch the value of '$FUN' after the case is completed ?
Or from the commands or functions ran such as do_change_pass
Perhaps a *) needs to be processed ?

Regards
Peasant.

I do not understand your questions.

case statement and if statement will return a value other that zero when they fail.
The values are numeric and indicate error codes - pretty normal in many languages.

For example in c you write int function_name (.... return X } Such syntax defines "int " as being passed from the function to the calling code.

Similar syntax must be in bash and that is what I am looking for.

case is not a function, but rather a compound command ( man bash for reference) just like while, select, for, if while etc...
There're no return value(s) ...

So how does the error message after esac || manages to execute ?

I am too new to get into terminology discussion , but per doc "case" returns value, it does not matter (to me) how it is called.

       case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac
              A case command first expands word, and tries to match it against each pattern in turn, using the same matching rules as  for  path
              name  expansion  (see  Pathname  Expansion  below).   The word is expanded using tilde expansion, parameter and variable expansion,
              arithmetic expansion, command substitution, process substitution and quote removal.  Each pattern examined is expanded using  tilde
              expansion,  parameter and variable expansion, arithmetic expansion, command substitution, and process substitution.  If the nocase
              match shell option is enabled, the match is performed without regard to the case of alphabetic characters.  When a match is  found,
              the corresponding list is executed.  If the ;; operator is used, no subsequent matches are attempted after the first pattern match.
              Using ;& in place of ;; causes execution to continue with the list associated with the next set of patterns.  Using ;;& in place of
              ;;  causes the shell to test the next pattern list in the statement, if any, and execute any associated list on a successful match.
              The exit status is zero if no pattern matches.  Otherwise, it is the exit status of the last command executed in list.

You're right. you can check $? for the returned status:

case
....
esac
if [ "${?}" -ne 0 ]; then
   echo NONzero
else
   echo zero
fi

FYI update

There are bash system special variables ($x) and this one is called

$? - The exit status of the most recently run process