1

I found some code in one of the answers here and accommodated it to my needs but now I have two questions:

Q1: how can I display the options text after the code in case statement finishes? So the user can see the options again.

Q2: Can I make it so that every option is displayed on its own line when I run the script? Currently it is not.

options=(
        "quit/exit"
    "new rational db"
    "run php for rational codebase"
    "run php for playground codebase"
   )

select option in "${options[@]}"; do
  case "$REPLY" in
       1) break;;
       2) sudo -i -u db2inst1 bash -c "db2stop force;";;
       3) rm /tmp/createDb2*;;
       4)  ;;               
  esac
done

1 Answer 1

1

Q1: add spaces to the end of any of the options to make it longer than 40 characters, for example:

options=(
        "quit/exit"
    "new rational db"
    "run php for rational codebase"
    "run php for playground codebase                       "
   )

Q2: Not sure if there is a more elegant way (didn't see in help select), but this should work:

finished=
while test ! "$finished"; do
    select option in "${options[@]}"; do
      case "$REPLY" in
           1) finished=1;;
           2) sudo -i -u db2inst1 bash -c "db2stop force;";;
           3) rm /tmp/createDb2*;;
           4)  ;;               
      esac
      break
    done
done
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .