- cp_yes_no - simple y/n dialog function
--- /dev/null
+# by ddzeko, Mon, 21 Mar 2005 13:35:42 +0100
+cn_yes_no () {
+ [ "$CP_SCRIPT_DEBUG" ] && set -vx
+ local prompt answer
+ prompt=$1
+ [ "$prompt" ] || prompt="Are you sure?"
+ RET=""
+
+ # check to prevent user from using this when debconf is active
+ # (it would break communication with its backend - uses stdin/out)
+ if [ "$DEBCONF_REDIR" ]; then
+ echo "cn_yes_no: debconf redirection detected" >&2
+ return 1
+ fi
+
+ echo -n "$prompt (y)es/(n)o: "
+ read answer
+ case $answer in
+ y*)
+ echo
+ RET=y
+ ;;
+ n*)
+ echo
+ RET=n
+ ;;
+ *)
+ echo
+ echo "Please read the message and choose y or n"
+ cn_yes_no
+ ;;
+ esac
+}