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