diff options
author | dteske <dteske@FreeBSD.org> | 2012-12-21 18:58:19 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2012-12-21 18:58:19 +0000 |
commit | 5e7ea05b1afc71ededb3af74c2ab29cec62cc286 (patch) | |
tree | b36ed1ce72c48c84674686128b0f6e806b3330e4 /usr.sbin/bsdconfig/startup/share | |
parent | 804c67a4867afb8b7ef41a3ade748cab870b788c (diff) | |
download | FreeBSD-src-5e7ea05b1afc71ededb3af74c2ab29cec62cc286.zip FreeBSD-src-5e7ea05b1afc71ededb3af74c2ab29cec62cc286.tar.gz |
Add much-needed dialog(1) --inputbox function for simplifying the process of
requesting input from the user.
Diffstat (limited to 'usr.sbin/bsdconfig/startup/share')
-rw-r--r-- | usr.sbin/bsdconfig/startup/share/rcconf.subr | 31 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/startup/share/rcedit.subr | 33 |
2 files changed, 8 insertions, 56 deletions
diff --git a/usr.sbin/bsdconfig/startup/share/rcconf.subr b/usr.sbin/bsdconfig/startup/share/rcconf.subr index 16cb290..efab30a 100644 --- a/usr.sbin/bsdconfig/startup/share/rcconf.subr +++ b/usr.sbin/bsdconfig/startup/share/rcconf.subr @@ -418,39 +418,16 @@ f_dialog_input_rclist() # f_dialog_input_rcvar() { - local msg="$msg_please_enter_rcvar_name" - local hline="$hline_alnum_tab_enter" - # # Loop until the user provides taint-free/valid input # - local size _input="$1" + local _input="$1" while :; do - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) # Return if user either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg_please_enter_rcvar_name" \ + "$_input" "$hline_alnum_tab_enter" + ) || return # Check for invalid entry (1of2) if ! echo "$_input" | grep -q "^[[:alpha:]_]"; then diff --git a/usr.sbin/bsdconfig/startup/share/rcedit.subr b/usr.sbin/bsdconfig/startup/share/rcedit.subr index 4905a18..1f38a5c 100644 --- a/usr.sbin/bsdconfig/startup/share/rcedit.subr +++ b/usr.sbin/bsdconfig/startup/share/rcedit.subr @@ -53,8 +53,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr # f_dialog_rcedit() { - local msg size retval var="$1" _input - local hline="$hline_alnum_punc_tab_enter" + local msg var="$1" _input msg=$( printf "$msg_please_enter_a_new_value" \ "$var" "$( f_sysrc_get_default "$var" )" ) @@ -67,34 +66,10 @@ f_dialog_rcedit() _input=$( f_sysrc_get "$var" ) fi - size=$( f_dialog_inputbox_size \ - "$DIALOG_TITLE" \ - "$DIALOG_BACKTITLE" \ - "$msg" \ - "$_input" \ - "$hline" ) - - local opterm="--" - [ "$USE_XDIALOG" ] && opterm= - - local dialog_inputbox - dialog_inputbox=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --inputbox \"\$msg\" $size \ - $opterm \"\$_input\" \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - - retval=$? - setvar DIALOG_INPUTBOX_$$ "$dialog_inputbox" - _input=$( f_dialog_inputstr ) - # Return if user has either pressed ESC or chosen Cancel/No - [ $retval -eq $SUCCESS ] || return $retval + _input=$( f_dialog_input "$msg" "$_input" \ + "$hline_alnum_punc_tab_enter" + ) || return # Return if the value has not changed from current local cur_val="$( f_sysrc_get "$var" )" |