summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/password
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-05-31 19:07:17 +0000
committerdteske <dteske@FreeBSD.org>2013-05-31 19:07:17 +0000
commita0eece46063b1db33804c35b64793e3afc2424c1 (patch)
tree2634f68f77f7c057b30aa67f1c494a01df2e22a7 /usr.sbin/bsdconfig/password
parent838ba827a2bbb59d8184419cf6632b7afa203afa (diff)
downloadFreeBSD-src-a0eece46063b1db33804c35b64793e3afc2424c1.zip
FreeBSD-src-a0eece46063b1db33804c35b64793e3afc2424c1.tar.gz
Improve portion of the dialog(1) API in dialog.subr responsible for
calculating widget sizes. Instead of forking a sub-shell to calculate the optimum size for a widget, use a byRef style call-out to set variables in the parent namespace. For example, instead of: size=$( f_dialog_buttonbox_size title btitle msg ) $DIALOG --title title --backtitle btitle --msgbox msg $size The new API replaces the above with the following: f_dialog_buttonbox_size height width title btitle msg $DIALOG --title title --backtitle btitle --msgbox msg $height $width This reduces the number of forks, improves performance, and makes the code more readable by revealing the argument-order for widget sizing. It also makes performing minor adjustments to the calculated values easier as you no longer have to split-out the response (which required knowledge of ordering so was counter-intuitive).
Diffstat (limited to 'usr.sbin/bsdconfig/password')
-rw-r--r--usr.sbin/bsdconfig/password/share/password.subr62
1 files changed, 33 insertions, 29 deletions
diff --git a/usr.sbin/bsdconfig/password/share/password.subr b/usr.sbin/bsdconfig/password/share/password.subr
index ba1f612..2d407c4 100644
--- a/usr.sbin/bsdconfig/password/share/password.subr
+++ b/usr.sbin/bsdconfig/password/share/password.subr
@@ -46,23 +46,25 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
f_dialog_input_password()
{
local hline="$hline_alnum_punc_tab_enter"
- local msg size rmsg rsize
+ local msg rmsg
msg=$( printf "$msg_enter_new_password" )
- size=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$msg" \
- "" \
- "$hline" )
+ local height1 width1
+ f_dialog_inputbox_size height1 width1 \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$msg" \
+ "" \
+ "$hline"
rmsg=$( printf "$msg_reenter_password" )
- rsize=$( f_dialog_inputbox_size \
- "$DIALOG_TITLE" \
- "$DIALOG_BACKTITLE" \
- "$rmsg" \
- "" \
- "$hline" )
+ local height2 width2
+ f_dialog_inputbox_size height2 width2 \
+ "$DIALOG_TITLE" \
+ "$DIALOG_BACKTITLE" \
+ "$rmsg" \
+ "" \
+ "$hline"
#
# Loop until the user provides taint-free/valid input
@@ -70,14 +72,15 @@ f_dialog_input_password()
local retval _password1 _password2
while :; do
local dialog_inputbox
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --insecure \
- --passwordbox \"\$msg\" $size \
+ dialog_inputbox=$( $DIALOG \
+ --title "$DIALOG_TITLE" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --hline "$hline" \
+ --ok-label "$msg_ok" \
+ --cancel-label "$msg_cancel" \
+ --insecure \
+ --passwordbox "$msg" \
+ $height1 $width1 \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
@@ -88,14 +91,15 @@ f_dialog_input_password()
# Return if user has either pressed ESC or chosen Cancel/No
[ $retval -eq $SUCCESS ] || return $retval
- dialog_inputbox=$( eval $DIALOG \
- --title \"\$DIALOG_TITLE\" \
- --backtitle \"\$DIALOG_BACKTITLE\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --insecure \
- --passwordbox \"\$rmsg\" $rsize \
+ dialog_inputbox=$( $DIALOG \
+ --title "$DIALOG_TITLE" \
+ --backtitle "$DIALOG_BACKTITLE" \
+ --hline "$hline" \
+ --ok-label "$msg_ok" \
+ --cancel-label "$msg_cancel" \
+ --insecure \
+ --passwordbox "$rmsg" \
+ $height2 $width2 \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
OpenPOWER on IntegriCloud