From c83cb8f996ff574d9f514492eb0ab87ddc9c3cad Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 3 Dec 2008 22:56:15 +0100 Subject: allow user to cancel in cli ask option --- src/core/libs/lib-ui.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core/libs/lib-ui.sh') diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index d54ea0d..61fface 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -155,6 +155,7 @@ ask_number () # $2 title # shift;shift; $@ list of options. first tag. then name. (eg tagA itemA "tag B" 'item B' ) # the response will be echoed to stdout. but also $ANSWER_OPTION will be set. take that because the former method seems to not work. +# $? if user cancelled. 0 otherwise ask_option () { [ "$var_UI_TYPE" = dia ] && { _dia_ask_option "$@" ; return $? ; } @@ -237,12 +238,15 @@ _cli_ask_option () echo "$1 ] $2" shift 2 done + echo "CANCEL ] CANCEL" [ -n "$DEFAULT" ] && echo -n " > [ $DEFAULT ] " [ -z "$DEFAULT" ] && echo -n " > " read ANSWER_OPTION [ -z "$ANSWER_OPTION" -a -n "$DEFAULT" ] && ANSWER_OPTION="$DEFAULT" debug "cli_ask_option: User choose $ANSWER_OPTION" echo "$ANSWER_OPTION" + [ "$ANSWER_OPTION" = CANCEL ] && return 1 + return 0 } -- cgit v1.2.3-54-g00ecf