diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2008-12-03 22:56:15 +0100 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2008-12-03 22:56:15 +0100 |
commit | c83cb8f996ff574d9f514492eb0ab87ddc9c3cad (patch) | |
tree | 862080c2c1ecddff9e529a73bad9080fe67690f1 /src | |
parent | 55d02e8eac1abf142e71dbefd80dd9afc5cf25b5 (diff) |
allow user to cancel in cli ask option
Diffstat (limited to 'src')
-rw-r--r-- | src/core/libs/lib-ui.sh | 4 |
1 files changed, 4 insertions, 0 deletions
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 } |