Bash case error

Please - this is my FIRST ever attempt on scrip and I just want simple answer if possible.

I am modifying existing and working script.

I just want to and more to it so I started with simple insertion of working code into menu.

I am doing OK, but I cannot figure out why I am executing this line of code

 esac || whiptail --msgbox "DEBUG ERROR There was an error running option 

I understand the "end of case" , but || (or?) does not makes sense to me for now.

I am enclosing PART what I feel is an "problem area"

    RET=$?
    if [ $RET -eq 1 ]; then
      do_finish
    elif [ $RET -eq 0 ]; then
      if is_pi ; then
        case "$FUN" in
          1\ *) do_change_pass ;;
          2\ *) do_network_menu ;;
          3\ *) do_boot_menu ;;
          4\ *) do_internationalisation_menu ;;
          5\ *) do_interface_menu ;;
          6\ *) do_overclock ;;
          7\ *) do_advanced_menu ;;
          8\ *) do_update ;;
          9\ *) do_about ;;
          10\ *) do_about ;;
          *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
        esac || whiptail --msgbox "DEBUG ERROR There was an error running option $FU$
      else
        case "$FUN" in
          1\ *) do_change_pass ;;
          2\ *) do_network_menu ;;
          3\ *) do_boot_menu ;;
          4\ *) do_internationalisation_menu ;;
          5\ *) do_ssh ;;

I am coding in C/C++ and know about switch / case construct , but I do not understand why duplicating item 9 and inserting it as item 10 is causing this error. It should just run same function as item 9 does.

The "menu" displays OK , but when I select the item 10 I get the DEBUG ERROR message. Is it possible I am getting the "programmer error ..." also but it is getting overridden by the next message?
Help will be much appreciated.

Welcome to the forum.

The || is the "control operator" in a bash "OR list". man bash :

So the construct is there to catch errors of case dealing with the various FUN s.

Be aware that $FU$ will expand to just $ (unless FU is defined somewhere in your script).

Try moving the second msgbox to another position to eliminate your "override suspicion"

Does your case work for other inputs, e.g. 3 , or 9 ? What exactly do you enter in either case, and what in the 10 case?
Are you aware that the shown snippet only has some improvement opportunities?

Thanks for reply.
(URL deleted - not allowed ) It never occurred to me that case returns value.

I'll follow you suggestions after I post this.

I am modifying "standard" configuration file to make sense of WiFi errors I am getting.

I am not too concerned if the file is perfect, I just need to make my modifications for now.

Would it be feasible to implement something like this - in pseudocode ?

...
esac || if debug 

      print error code 

      else
      just print the original message 

When I gain some more experience I would like to make the "|| command " as a function passing the error number (?) and the variable message to it.

Thanks

What code ?

I did not post any such thing.

If you are only seeing the DEBUG ERROR message box when you run do_about , it means that do_about is exiting with a non-zero exit code. The exit status of a case statement is the exit status of the last command executed in the command list for the matched pattern or zero if no pattern matched.

The text you included in post #3 in this thread (that Neo edited for you to contain CODE tags) did indeed include the shell script pseudo-code which without CODE tags displays as:
...
esac || if debug

print error code

else
just print the original message

With CODE tags that pseudo-code appears as:

...
esac || if debug 

      print error code 

      else
      just print the original message

Please use CODE tags when displaying sample input, sample output, and code (or pseudo-code) segments.

OK, I get it.

I have been thru this before on another forum and will risk repeating my concerns here.

Especially when I do not see HOW to copy the tagged code block.

But it may be there and I just do not readily see it. ( Another favorite of mine - "users fault')

WHY use code tags if mouse "cut and paste " works ?

Is it one of those artifacts "just because "?

Perhaps there are "savings" with code tags.

Personally I like KISS principle better.

It almost seems that code tags are used so post can be scrutinized for format , which is much easier than analyzing them for contents.

(Sorry) for venting, but I grew up when peoples ideas written "on napkin" were acceptable...

Cheers

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

We are very sorry we are being forced to post this. 



We did very detailed analysis of our post and resulting discussion based on the original post where we asked for help to  resolve simple case command error issue. 



On the scale "good , bad and ugly"  - forum score is 

10% good ( case command returns value ) 

80 % bad 

10 % ugly 



The original cause of the error was newer discussed or resolved. 



Posting specific about our rating of the one sided discussion would be pointless and 

more waste of our time. 

We have learned our lesson and would ask to stop sending / posting instructions on how to write and keep our mouth shut so not to disturb this fine forum.