blob: cbed0e03017549584196c0c0679f41608d6a2dfc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#! /bin/bash
# Usage: yesno prompt...
default=
if [ $1 == "-y" ]
then default='y'; shift
fi
if [ $# -eq 0 ]
then prompt="yes or no: "
else prompt="$*"
fi
if [ ! -z $default ]; then
prompt+="[y]"
fi
while true
do
read -p "$prompt" || exit 1
if [ -z "$REPLY" -a ! -z $default ]
then REPLY=$default
fi
case "$REPLY" in
y*|Y*) exit 0;;
n*|n*) exit 1;;
*) echo "Answer yes or no please";;
esac
done
|