summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/share/device.subr
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-06-01 23:58:44 +0000
committerdteske <dteske@FreeBSD.org>2013-06-01 23:58:44 +0000
commit9e2431c34dc087e0ff7bb1a5ae076865b37fd54e (patch)
treeaff553824a76a9a13ba24f03ece60b3c50def184 /usr.sbin/bsdconfig/share/device.subr
parent2201176ef968245558d98feec1de87cfdca36bf4 (diff)
downloadFreeBSD-src-9e2431c34dc087e0ff7bb1a5ae076865b37fd54e.zip
FreeBSD-src-9e2431c34dc087e0ff7bb1a5ae076865b37fd54e.tar.gz
Improve portion of the dialog(1) API in dialog.subr responsible for
retrieving stored data (for the --menu, --calendar, --timebox, --checklist, and --radiolist 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 some very long time, so the need to always store the return status of dialog(1) and then call some function to clean-up is long-deprecated. The function that used to do the clean-up was f_dialog_menutag(). We really don't need f_dialog_menutag() for its originally designed purpose, as all dialog invocations (even when in a sub-shell) do not use temporary files anymore. However, we do need to keep f_dialog_menutag() around because it still fills the need of being able to abstract the procedure for fetching stored data provided by functions that display the aforementioned widgets. In re-designing f_dialog_menutag(), four important changes are made: 1. Rename f_dialog_menutag() to f_dialog_menutag_fetch() 2. Introduce the new first-argument of $var_to_set to reduce number of forks 3. Create a corresponding f_dialog_menutag_store() to abstract the storage 4. Offload the sanitization to a new function, f_dialog_data_sanitize() NOTE: That last one is important. Not all functions need to store their data for later fetching, meanwhile every invocation of dialog should be sanitized (as we learned early-on in the i18n-effort -- underlying libraries will spit warnings to stderr for bad values of $LANG and since dialog outputs its responses to stderr, we need to sanitize every response of these warnings). These changes greatly improve readbaility and also improve performance by reducing unnecessary forking.
Diffstat (limited to 'usr.sbin/bsdconfig/share/device.subr')
-rw-r--r--usr.sbin/bsdconfig/share/device.subr4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/bsdconfig/share/device.subr b/usr.sbin/bsdconfig/share/device.subr
index f973bb8..f724af4 100644
--- a/usr.sbin/bsdconfig/share/device.subr
+++ b/usr.sbin/bsdconfig/share/device.subr
@@ -619,6 +619,7 @@ f_device_menu()
case $- in *e*) errexit=1; esac
set +e
+ local mtag
while :; do
mtag=$( eval $DIALOG \
--title \"\$title\" \
@@ -648,8 +649,7 @@ f_device_menu()
if [ $retval -eq 0 ]; then
# Clean up the output of [X]dialog(1) and return it
- setvar DIALOG_MENU_$$ "$mtag"
- mtag=$( f_dialog_menutag )
+ f_dialog_data_sanitize mtag
echo "$mtag" >&2
fi
OpenPOWER on IntegriCloud