summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/share/media/any.subr
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/share/media/any.subr
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/share/media/any.subr')
-rw-r--r--usr.sbin/bsdconfig/share/media/any.subr35
1 files changed, 19 insertions, 16 deletions
diff --git a/usr.sbin/bsdconfig/share/media/any.subr b/usr.sbin/bsdconfig/share/media/any.subr
index 1193282..11fe429 100644
--- a/usr.sbin/bsdconfig/share/media/any.subr
+++ b/usr.sbin/bsdconfig/share/media/any.subr
@@ -69,7 +69,7 @@ f_media_get_type()
f_dialog_title_restore
local prompt="$msg_choose_installation_media_description"
local hline="$hline_choose_help_for_more_information_on_media_types"
- local menu_list size
+ local menu_list
menu_list="
'1 $msg_cd_dvd' '$msg_install_from_a_freebsd_cd_dvd'
@@ -86,26 +86,29 @@ f_media_get_type()
'X $msg_options' '$msg_view_set_various_media_options'
" # END-QUOTE
- size=$( eval f_dialog_menu_size \
- \"\$title\" \
- \"\$btitle\" \
- \"\$prompt\" \
- \"\$hline\" \
- $menu_list )
+ local height width rows
+ eval f_dialog_menu_size height width rows \
+ \"\$title\" \
+ \"\$btitle\" \
+ \"\$prompt\" \
+ \"\$hline\" \
+ $menu_list
local dialog_menu
while :; do
dialog_menu=$( eval $DIALOG \
- --title \"\$title\" \
- --backtitle \"\$btitle\" \
- --hline \"\$hline\" \
- --ok-label \"\$msg_ok\" \
- --cancel-label \"\$msg_cancel\" \
- --help-button \
- --help-label \"\$msg_help\" \
- ${USE_XDIALOG:+--help \"\"} \
- --menu \"\$prompt\" $size $menu_list \
+ --title \"\$title\" \
+ --backtitle \"\$btitle\" \
+ --hline \"\$hline\" \
+ --ok-label \"\$msg_ok\" \
+ --cancel-label \"\$msg_cancel\" \
+ --help-button \
+ --help-label \"\$msg_help\" \
+ ${USE_XDIALOG:+--help \"\"} \
+ --menu \"\$prompt\" \
+ $height $width $rows \
+ $menu_list \
2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
)
local retval=$?
OpenPOWER on IntegriCloud