| 1 | #!/bin/bash |
| 2 | |
| 3 | PS3='Choose your favorite vegetable: ' # Sets the prompt string. |
| 4 | # Otherwise it defaults to #? . |
| 5 | |
| 6 | echo |
| 7 | |
| 8 | select vegetable in "beans" "carrots" "potatoes" "onions" "rutabagas" |
| 9 | do |
| 10 | echo |
| 11 | echo "Your favorite veggie is $vegetable." |
| 12 | echo "Yuck!" |
| 13 | echo |
| 14 | break # What happens if there is no 'break' here? |
| 15 | done |
| 16 | |
| 17 | exit |
| 18 | |
| 19 | # Exercise: |
| 20 | # -------- |
| 21 | # Fix this script to accept user input not specified in |
| 22 | #+ the "select" statement. |
| 23 | # For example, if the user inputs "peas," |
| 24 | #+ the script would respond "Sorry. That is not on the menu." |