Select command help with blank input value

I have a select menu driven script using a case statment and cannot control what happens after a user's input is just <ENTER> or the <SPACEBAR>+<ENTER>. I want it to just hit the "MAIN" function and not redraw the options. I've look everywhere for the answer and am at a loss.

Here's the code:
-------------------------------------------------------------------

 #!/usr/bin/ksh

MAIN ()
{
clear
echo " Main Menu"
echo "--------------------------"
PS3=$'--------------------------\n\nSelect Option: '

select option in "Refresh" "Exit" "Stop" "Start"
do
        case ${option} in
                   '') echo "Invalid Choice";sleep 2;MAIN;;
               "Exit") exit;;
            "Refresh") MAIN;;
               "Stop") echo STOP;exit;;
              "Start") echo START;exit;;
                      
        esac
done

}

MAIN

--------------------------------------------------------------------

Here's what the screen looks like when executed:

Main Menu
--------------------------
1) Refresh
2) Exit
3) Stop
4) Start
--------------------------

Select Option:

When you press <ENTER> or the <SPACEBAR>+<ENTER> from this menu it shows this:

Main Menu
--------------------------
1) Refresh
2) Exit
3) Stop
4) Start
--------------------------

Select Option: 
1) Refresh
2) Exit
3) Stop
4) Start
--------------------------

Select Option: [/COLOR]

I figured that the '') in the case statement would work but it is only handling any selection that is not valid. I figured that <ENTER> or the <SPACEBAR>+<ENTER> would be caught under this but it isn't.

If anyone know how to correct this your would be much appreciated.

<space><enter> behave as you expected: "invalid choice " is displayed for 2 seconds, and then MAIN is executed (BTW, be careful with unterminated recursion here!).
The behaviour of <enter> alone is a feature of the select command, see its man page.

<enter> or <space><enter> are not behaving as expected it does not go to "invalid choice" for 2 secs, then MAIN, it's just displaying the menu list down on the screen over and over, hence this is my issue I'm wanting to correct. That behaviour doesn't not seem right.

I didn't think there would be a solid answer on this since I could not find any information online about this issue.

What if something else is entered, i.e. not a number? Consider also a wildcard option for your case statement:-

case this in
   a) x=1 ;;
   b) x=2 ;;
   c) x=3 ;;
   *) echo "Invalid" ;;
esac

I thinks that select is working as designed. It is simple enough and work, but not that flexible, however I am very happy to use it. Perhaps you could allow any input and then work on the choice outside of the select loop, just calling it to display your menu.

Robin

Robin