複数の項目から選択する(bash)

bashにはユーザーに複数の項目から数字で選択させるための
select文が用意されている

#!/bin/sh
#select.sh

#シェル変数PS3の内容がプロンプトとして表示される
PS3="Which fruits do you like? "
select fruit in apples oranges bananas "I'm full!"; do
    case "$fruit" in
        "I'm full!")
            break;;
        "") 
            echo "Pardon me?";;
        *) 
            echo "Okey I will give you some $fruit.";;
    esac    
done
echo "Good bye."
$ ./select.sh 
1) apples
2) oranges
3) bananas
4) I'm full!
Which fruits do you like? 1
Okey I will give you some apples.
Which fruits do you like? 2
Okey I will give you some oranges.
Which fruits do you like? 3
Okey I will give you some bananas.
Which fruits do you like? 4
Good bye.