I'm working with select and case in bash. I currently have nine options, which makes a nice, tidy, 3x3 grid of options, but it displays like so:
1) show all elements 4) write to file 7) clear elements
2) add elements 5) generate lines 8) choose file
3) load file 6) clear file 9) exit
I'd prefer if it displayed in rows before columns:
1) show all elements 2) add elements 3) load file
4) write to file 5) generate lines 6) clear file
7) clear elements 8) choose file 9) exit
Is there any way to accomplish this? Preferably something easy to set and unset within a script, like a shell option. If it matters, the options are stored in an array, and referenced in the case blocks by the index of the array.
OPTIONS=("show all elements" "add elements" "load file" "write to file" "generate lines" "clear file" "clear elements" "choose file" "exit")
...
select opt in "${OPTIONS[@]}"
do
case $opt in
"${OPTIONS[0]}")
...
"${OPTIONS[8]}")
echo "Bye bye!"
exit 0
break
;;
*)
echo "Please enter a valid option."
esac
done