r25:
[carnet-tools-cn.git] / functions-more.sh
1 # by ddzeko, Mon, 21 Mar 2005 13:35:42 +0100
2 cp_yes_no () {
3   [ "$CP_SCRIPT_DEBUG" ] && set -vx
4   local prompt answer
5   prompt="$1"
6   [ "$prompt" ] || prompt="Are you sure?"
7   RET=""
8   
9   # check to prevent user from using this when debconf is active
10   # (it would break communication with its backend - uses stdin/out)
11   if [ "$DEBCONF_REDIR" ]; then
12     echo "cn_yes_no: debconf redirection detected" >&2
13     return 1
14   fi
15   
16   echo -n "$prompt (y)es/(n)o: "
17   read answer
18   case "$answer" in
19     y*)
20       echo
21       RET=y
22       ;;
23     n*)
24       echo
25       RET=n
26       ;;
27     *)
28       echo
29       echo "Please read the message and choose y or n"
30       cn_yes_no
31       ;;
32   esac
33 }