Two columns output in simple case menu?

EDIT : System used : Any Linux distribution.

Hello everyone,

I m having quite a headache trying to figure out why I m having a 2 columns output in the following code :

 #!/bin/ksh
 
 menu_rotation()
 {
 #Variables
 CHOIX1="Rotation 1"
 CHOIX2="Rotation 2"
 CHOIX3="Rotation 3"
 CHOIX4="Rotation 4"
 CHOIX5="Rotation 5"
 CHOIX6="Rotation 6"
 CHOIX7="Rotation 7"
 CHOIX8="Rotation 8"
 #/Variables
 
 clear
 echo
 echo ============================
 echo "      Menu Rotation      "
 echo ============================
 PS3="Votre choix "
 
 select menu in "$CHOIX1" "$CHOIX2" "$CHOIX3" "$CHOIX4" "$CHOIX5" "$CHOIX6" "$CHOIX7" "$CHOIX8" "Back" "Quit"
     do
         case $menu in
         "${CHOIX1}")    echo
         echo "Choix 1"
         break 1 ;;
         
         "${CHOIX2}")    echo
         echo "Choix 1"
         break 1 ;;
         
         "${CHOIX3}")    echo
         echo "Choix 1"
         break 1 ;;
         
         "${CHOIX4}")    echo
         echo "Choix 1"
         break 1 ;;
         
         "${CHOIX5}")    echo
         echo "Choix 1"
         break 1 ;;
         
         "${CHOIX6}")    echo
         echo "Choix 1"
         break 1 ;;
         
         "${CHOIX7}")    echo
         echo "Choix 1"
         break 1 ;;
         
         "${CHOIX8}")    echo
         echo "Choix 1"
         break 1 ;;
         
         "Back")       echo
         main_menu
         break 2 ;;
         
         "Quit")      echo
         exit ;;
         
         *)              echo
         echo "Mauvaise r�ponse"
         esac
     done             
 }
 menu_rotation
 

Output shows like this :

So it's technically working but the output is kinda ugly...

What I intended was having the following output line by line :

Also, I m having a 3 columns output (3 columns of 3 lines) using the same code in an other function with different variables. :wall:

If anyone got any idea I d appreciate it !

Thanks

My shell doesn't do that; not even the ksh I've got installed does that. This would seem to be shell and system specific.

So, what's your system? What's the version of your shell?

Works on every Linux I ve been using so far.
Cent OS 6.0 and Linux xxx 2.6.9-42.ELhugemem

Most linux doesn't even come with KSH at all.

Which version of KSH are you installing?

echo $KSH_VERSION
@(#)PD KSH v5.2.14 99/07/13.2

How strange, I have the exact same version you do. And i get the same behavior when running your code, but not mine.

However mine shows up much prettier:

============================
      Menu Rotation
============================
 1) Rotation 1                           6) Rotation 6
 2) Rotation 2                           7) Rotation 7
 3) Rotation 3                           8) Rotation 8
 4) Rotation 4                           9) Back
 5) Rotation 5                          10) Quit
Votre choix

---------- Post updated at 11:49 AM ---------- Previous update was at 11:49 AM ----------

Looking in man ksh I don't see any option to change select's behavior.

Anyone else might have an idea for a better output using this menu?

Thanks

I get 5 columns... :frowning:

============================
      Menu Rotation
============================
1) Rotation 1    3) Rotation 3   5) Rotation 5   7) Rotation 7   9) Back
2) Rotation 2    4) Rotation 4   6) Rotation 6   8) Rotation 8  10) Quit
Votre choix 1

:eek:

So you see my dilema :slight_smile:

FWIW, works fine on Solaris:

============================
      Menu Rotation
============================
 1) Rotation 1
 2) Rotation 2
 3) Rotation 3
 4) Rotation 4
 5) Rotation 5
 6) Rotation 6
 7) Rotation 7
 8) Rotation 8
 9) Back
10) Quit
Votre choix

According to David Korn:

KSH-93 - Frequently Asked Questions #Q17

I would install a genuine ksh93 package and try again...

1 Like

Ok indeed I just tested this @ home on a different KSH version and it's working fine.

Oh well, I don't think upgrading this at the office won't be easy.

Thanks a lot for the troubleshooting tho, got the answer i was looking for :b: