diff options
author | Devin Teske <dteske@FreeBSD.org> | 2013-06-02 05:45:25 +0000 |
---|---|---|
committer | Devin Teske <dteske@FreeBSD.org> | 2013-06-02 05:45:25 +0000 |
commit | ec7120b5b2d110c16e43de0e66e7f971efd52717 (patch) | |
tree | c82ae86b5bfe7b5e527099673025931ffda2e584 /usr.sbin/bsdconfig/startup | |
parent | 45de1d006d9c93c49834c4395eab7e434cb15745 (diff) | |
download | src-ec7120b5b2d110c16e43de0e66e7f971efd52717.tar.gz src-ec7120b5b2d110c16e43de0e66e7f971efd52717.zip |
Similar to r251236, improve the portion of dialog(1) API in dialog.subr
responsible for retrieving stored input (for the --inputbox and --password
widgets).
When we (Ron McDowell and I) developed the first version of bsdconfig, it
used temporary files to store responses from dialog(1). That hasn't been
true for a very long time, so the need to always execute some clean-up
function is long-deprecated. The function that used to perform these clean-
up routines for these widgets was f_dialog_inputstr().
We really don't need f_dialog_inputstr() for its originally designed purpose
as all dialog invocations no longer require temporary files.
Just as in r251236, redesign f_dialog_inputstr() in the following four ways:
1. Rename f_dialog_inputstr() to f_dialog_inputstr_fetch()
2. Introduce the new first-argument of $var_to_set to reduce forking
3. Create a corresponding f_dialog_inputstr_store() to abstract storage
4. Offload the sanitization to a new function, f_dialog_line_sanitize()
It should be noted that f_dialog_line_sanitize() -- unlike its cousin from
SVN r251236, f_dialog_data_sanitize() -- trims leading/trailing whitespace
from the user's input. This helps prevent errors and common mistakes caused
by the fact that the new cdialog implementation allows the right-arrow
cursor key to go beyond the last byte of realtime input (adding whitespace
at the end of the typed value).
While we're centralizing the sanitization, let's rewrite f_dialog_input()
while we're here to likewise reduce forking. The f_dialog_input() function
now expects the first argument of $var_to_set instead of producing results
on standard-out.
These changes greatly improve readability and also improve performance.
Notes
Notes:
svn path=/head/; revision=251242
Diffstat (limited to 'usr.sbin/bsdconfig/startup')
-rwxr-xr-x | usr.sbin/bsdconfig/startup/misc | 2 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/startup/share/rcconf.subr | 5 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/startup/share/rcedit.subr | 5 |
3 files changed, 5 insertions, 7 deletions
diff --git a/usr.sbin/bsdconfig/startup/misc b/usr.sbin/bsdconfig/startup/misc index c964129806eb..6e33462456ff 100755 --- a/usr.sbin/bsdconfig/startup/misc +++ b/usr.sbin/bsdconfig/startup/misc @@ -303,7 +303,7 @@ dialog_input_value() local prompt="$1" _input="$2" f_dialog_title "$msg_value_required" - _input=$( f_dialog_input "$prompt" "$_input" "$hline_alnum_tab_enter" ) + f_dialog_input _input "$prompt" "$_input" "$hline_alnum_tab_enter" local retval=$? f_dialog_title_restore diff --git a/usr.sbin/bsdconfig/startup/share/rcconf.subr b/usr.sbin/bsdconfig/startup/share/rcconf.subr index 1c641378ebff..ed8553ab9021 100644 --- a/usr.sbin/bsdconfig/startup/share/rcconf.subr +++ b/usr.sbin/bsdconfig/startup/share/rcconf.subr @@ -454,9 +454,8 @@ f_dialog_input_rcvar() while :; do # Return if user either pressed ESC or chosen Cancel/No - _input=$( f_dialog_input "$msg_please_enter_rcvar_name" \ - "$_input" "$hline_alnum_tab_enter" - ) || return + f_dialog_input _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 cb4a4116961e..64ee1ccf0d84 100644 --- a/usr.sbin/bsdconfig/startup/share/rcedit.subr +++ b/usr.sbin/bsdconfig/startup/share/rcedit.subr @@ -68,9 +68,8 @@ f_dialog_rcedit() fi # Return if user has either pressed ESC or chosen Cancel/No - _input=$( f_dialog_input "$msg" "$_input" \ - "$hline_alnum_punc_tab_enter" - ) || return + f_dialog_input _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" )" |