From: Damir Dzeko Date: Mon, 21 Mar 2005 12:48:18 +0000 (+0000) Subject: r16: More untested functions. X-Git-Tag: debian/3.0.0~89 X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=commitdiff_plain;h=80c3351124680d06fbbfa9a43dfd359d00246c3c;p=carnet-upgrade.git r16: More untested functions. - cp_yes_no - simple y/n dialog function --- diff --git a/functions-more.sh b/functions-more.sh new file mode 100644 index 0000000..be66994 --- /dev/null +++ b/functions-more.sh @@ -0,0 +1,33 @@ +# 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 +}