add README and examples
[gemrepl.git] / examples / choice.sh
blob91e44831ae2e01fb28f50b93e91166729caab673
1 #!/bin/sh
2 # A very simple example to demonstrate mixing options given by links and
3 # free-form input.
5 while true; do
6 cat <<EOF
7 What's your favourite colour?
8 => ?red Red
9 => ?green Green
10 => ?octarine Octarine
11 => ?!? [Something else]
12 EOF
13 read colour
14 cat <<EOF
15 Hmm... $colour, eh? It has its virtues, I suppose.
16 But are you sure really sure $colour is your favourite?
17 => ?yes Yes
18 => ?no No
19 EOF
20 while read conf; do
21 if [ "$conf" == yes ]; then
22 echo "Fine."
23 exit
24 elif [ "$conf" == no ]; then
25 echo "Hmm, let's try this again then."
26 break
27 else
28 echo "Pardon? Was that yes or no?"
30 done
31 done