diff options
-rw-r--r-- | src/core/libs/lib-ui-interactive.sh | 4 | ||||
-rw-r--r-- | src/core/libs/lib-ui.sh | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index d5d37c8..744dc54 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -325,7 +325,7 @@ interactive_filesystem () then default= [ -n "$fs_label" ] && default="$fs_label" - ask_string "Enter the label/name for $part" "$default" || return 1 + ask_string "Enter the label/name for $part" "$default" 0 || return 1 fs_label=$ANSWER_STRING fi @@ -359,7 +359,7 @@ interactive_filesystem () default= [ -n "$fs_opts" ] && default="$fs_opts" program=`get_filesystem_program $fs_type` - ask_string "Enter any additional opts for $program" "$default" || return 1 + ask_string "Enter any additional opts for $program" "$default" 0 || return 1 fs_opts=$(sed 's/ /_/g' <<< "$ANSWER_STRING") #TODO: clean up all whitespace (tabs and shit) [ -z "$fs_type" ] && fs_type=no_type diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index 6f31887..679a182 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -173,6 +173,7 @@ ask_password () # ask for a string. # $1 question # $2 default (optional) +# $3 exitcode to use when string is empty and there was no default, or default was ignored (1 default) # echo's the string the user gave. # returns 1 if the user cancelled, 0 otherwise ask_string () @@ -302,11 +303,13 @@ _dia_ask_password () _dia_ask_string () { + exitcode=${3:-1} _dia_DIALOG --inputbox "$1" 8 65 "$2" 2>$ANSWER ret=$? ANSWER_STRING=`cat $ANSWER` echo $ANSWER_STRING debug "_dia_ask_string: user entered $ANSWER_STRING" + [ -z "$ANSWER_STRING" ] && return $exitcode return $ret } @@ -407,8 +410,10 @@ _cli_ask_password () } +# $3 -z string behavior: always take default if applicable, but if no default then $3 is the returncode (1 is default) _cli_ask_string () { + exitcode=${3:-1} echo "$1: " [ -n "$2" ] && echo "(Press enter for default. Default: $2)" echo -n ">" @@ -421,7 +426,7 @@ _cli_ask_string () then ANSWER_STRING=$2 else - return 1 + return $exitcode fi fi return 0 |