Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jun 2013 09:02:12 +0000 (UTC)
From:      Devin Teske <dteske@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r251244 - in head/usr.sbin/bsdconfig: . console mouse networking security share startup timezone usermgmt
Message-ID:  <201306020902.r5292CPU090179@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dteske
Date: Sun Jun  2 09:02:12 2013
New Revision: 251244
URL: http://svnweb.freebsd.org/changeset/base/251244

Log:
  Improve the dialog(1) API in dialog.subr by adding f_dialog_default_store()
  and f_dialog_default_fetch(). Operating similar to functions introduced by
  SVN r251236 and r251242, these functions operate as a pair for helping track
  the default-item data (for the --menu, --checklist, and --radiolist
  widgets).
  
  This replaces the direct usage of a global to store the data with an
  abstract method for readability and to centralize the code.

Modified:
  head/usr.sbin/bsdconfig/bsdconfig
  head/usr.sbin/bsdconfig/console/console
  head/usr.sbin/bsdconfig/mouse/mouse
  head/usr.sbin/bsdconfig/networking/networking
  head/usr.sbin/bsdconfig/security/security
  head/usr.sbin/bsdconfig/share/dialog.subr
  head/usr.sbin/bsdconfig/startup/misc
  head/usr.sbin/bsdconfig/startup/rcconf
  head/usr.sbin/bsdconfig/startup/rcdelete
  head/usr.sbin/bsdconfig/startup/rcvar
  head/usr.sbin/bsdconfig/startup/startup
  head/usr.sbin/bsdconfig/timezone/timezone
  head/usr.sbin/bsdconfig/usermgmt/groupinput
  head/usr.sbin/bsdconfig/usermgmt/userinput
  head/usr.sbin/bsdconfig/usermgmt/usermgmt

Modified: head/usr.sbin/bsdconfig/bsdconfig
==============================================================================
--- head/usr.sbin/bsdconfig/bsdconfig	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/bsdconfig	Sun Jun  2 09:02:12 2013	(r251244)
@@ -146,6 +146,7 @@ dialog_menu_main()
 	local btitle="$DIALOG_BACKTITLE"
 	local prompt="$msg_menu_text"
 	local menu_list
+	local defaultitem= # Calculated below
 
 	menu_list="
 		'X' '$msg_exit'  '$msg_exit_bsdconfig'
@@ -187,6 +188,9 @@ dialog_menu_main()
 	                                  \"\"         \
 	                                  $menu_list
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
 		--clear                                 \
@@ -198,7 +202,7 @@ dialog_menu_main()
 		--help-button                           \
 		--help-label \"\$msg_help\"             \
 		${USE_XDIALOG:+--help \"\"}             \
-		--default-item \"\$DEFAULTITEM_$$\"     \
+		--default-item \"\$defaultitem\"        \
 		--menu \"\$prompt\"                     \
 		$height $width $rows                    \
 		$menu_list                              \
@@ -209,7 +213,7 @@ dialog_menu_main()
 	f_dialog_menutag_store "$menu_choice"
 
 	# Only update default-item on success
-	[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
+	[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
 
 	return $retval
 }

Modified: head/usr.sbin/bsdconfig/console/console
==============================================================================
--- head/usr.sbin/bsdconfig/console/console	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/console/console	Sun Jun  2 09:02:12 2013	(r251244)
@@ -51,6 +51,7 @@ dialog_menu_main()
 	local menu_list
 	local hline="$hline_configure_system_console_settings"
 	local prompt="$msg_console_menu_text"
+	local defaultitem= # Calculated below
 
 	menu_list="
 		'X $msg_exit'      '$msg_exit_this_menu'
@@ -70,23 +71,26 @@ dialog_menu_main()
 	                        \"\$hline\"            \
 	                        $menu_list
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
-		--title \"\$DIALOG_TITLE\"          \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$prompt\"                 \
-		$height $width $rows                \
-		$menu_list                          \
+		--title \"\$DIALOG_TITLE\"         \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
+		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?
 	f_dialog_data_sanitize menu_choice
 	f_dialog_menutag_store "$menu_choice"
-	setvar DEFAULTITEM_$$ "$menu_choice"
+	f_dialog_default_store "$menu_choice"
 	return $retval
 }
 

Modified: head/usr.sbin/bsdconfig/mouse/mouse
==============================================================================
--- head/usr.sbin/bsdconfig/mouse/mouse	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/mouse/mouse	Sun Jun  2 09:02:12 2013	(r251244)
@@ -51,6 +51,7 @@ dialog_menu_main()
 	local menu_list
 	local hline=""
 	local prompt="$msg_menu_text"
+	local defaultitem= # Calculated below
 
 	menu_list="
 		'X $msg_exit'    '$msg_exit_this_menu'
@@ -69,23 +70,26 @@ dialog_menu_main()
 	                        \"\$hline\"            \
 	                        $menu_list
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
-		--title \"\$DIALOG_TITLE\"          \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$prompt\"                 \
-		$height $width $rows                \
-		$menu_list                          \
+		--title \"\$DIALOG_TITLE\"         \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
+		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?
 	f_dialog_data_sanitize menu_choice
 	f_dialog_menutag_store "$menu_choice"
-	setvar DEFAULTITEM_$$ "$menu_choice"
+	f_dialog_default_store "$menu_choice"
 	return $retval
 }
 

Modified: head/usr.sbin/bsdconfig/networking/networking
==============================================================================
--- head/usr.sbin/bsdconfig/networking/networking	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/networking/networking	Sun Jun  2 09:02:12 2013	(r251244)
@@ -50,6 +50,7 @@ dialog_menu_main()
 {
 	local menu_list
 	local hline="$hline_arrows_tab_enter"
+	local defaultitem= # Calculated below
 
 	menu_list="
 		'X' '$msg_exit'
@@ -67,23 +68,26 @@ dialog_menu_main()
 	                        \"\$hline\"            \
 	                        $menu_list
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
-		--title \"\$DIALOG_TITLE\"          \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\"                         \
-		$height $width $rows                \
-		$menu_list                          \
+		--title \"\$DIALOG_TITLE\"         \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\"                        \
+		$height $width $rows               \
+		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?
 	f_dialog_data_sanitize menu_choice
 	f_dialog_menutag_store "$menu_choice"
-	setvar DEFAULTITEM_$$ "$menu_choice"
+	f_dialog_default_store "$menu_choice"
 	return $retval
 }
 

Modified: head/usr.sbin/bsdconfig/security/security
==============================================================================
--- head/usr.sbin/bsdconfig/security/security	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/security/security	Sun Jun  2 09:02:12 2013	(r251244)
@@ -54,7 +54,7 @@ dialog_menu_main()
 	local prompt="$msg_menu_text"
 
 	# Obtain default-item (adjusted below for dynamic tags)
-	f_getvar DEFAULTITEM_$$ defaultitem
+	f_dialog_default_fetch defaultitem
 	local ditem="${defaultitem%%[$IFS]*}"
 
 	menu_list="
@@ -123,7 +123,7 @@ dialog_menu_main()
 	f_dialog_menutag_store "$menu_choice"
 
 	# Only update default-item on success
-	[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
+	[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
 
 	return $retval
 }

Modified: head/usr.sbin/bsdconfig/share/dialog.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/dialog.subr	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/share/dialog.subr	Sun Jun  2 09:02:12 2013	(r251244)
@@ -1757,6 +1757,45 @@ f_dialog_menutag_fetch()
 	return $SUCCESS
 }
 
+# f_dialog_default_store [-s] $text
+#
+# Store some text to be used later as the --default-item argument to dialog(1)
+# (or Xdialog(1)) for --menu, --checklist, and --radiolist widgets. Retrieve
+# the text later with f_dialog_menutag_fetch(). If the first argument is `-s',
+# the text is sanitized before being stored.
+#
+f_dialog_default_store()
+{
+	local sanitize=
+	[ "$1" = "-s" ] && sanitize=1 && shift 1 # -s
+	local text="$1"
+
+	# Sanitize the defaulitem before storing it if desired
+	[ "$sanitize" ] && f_dialog_data_sanitize text
+
+	setvar DEFAULTITEM_$$ "$text"
+}
+
+# f_dialog_default_fetch [$var_to_set]
+#
+# Obtain text to be used with the --default-item argument of dialog(1) (or
+# Xdialog(1)) (previously stored with f_dialog_default_store() above). If
+# $var_to_set is NULL or missing, output is printed to stdout (which is less
+# recommended due to performance degradation; in a loop for example).
+#
+f_dialog_default_fetch()
+{
+	local __var_to_set="$1" __cp
+
+	debug= f_getvar DEFAULTITEM_$$ "${__var_to_set:-__cp}" # get the data
+	setvar DEFAULTITEM_$$ "" # scrub memory in case data was sensitive
+
+	# Return the data on standard-out if desired
+	[ "$__var_to_set" ] || echo "$__cp"
+
+	return $SUCCESS
+}
+
 # f_dialog_menutag2item $tag_chosen $tag1 $item1 $tag2 $item2 ...
 #
 # To use the `--menu' option of dialog(1) you must pass an ordered list of

Modified: head/usr.sbin/bsdconfig/startup/misc
==============================================================================
--- head/usr.sbin/bsdconfig/startup/misc	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/startup/misc	Sun Jun  2 09:02:12 2013	(r251244)
@@ -61,7 +61,7 @@ dialog_menu_main()
 	local prompt="$msg_miscellaneous_menu_text"
 
 	# Obtain default-item (adjusted below for dynamic tags)
-	f_getvar DEFAULTITEM_$$ defaultitem
+	f_dialog_default_fetch defaultitem
 	local ditem="${defaultitem%%[$IFS]*}"
 
 	menu_list="
@@ -289,7 +289,7 @@ dialog_menu_main()
 	local retval=$?
 	f_dialog_data_sanitize menu_choice
 	f_dialog_menutag_store "$menu_choice"
-	setvar DEFAULTITEM_$$ "$menu_choice"
+	f_dialog_default_store "$menu_choice"
 	return $retval
 }
 

Modified: head/usr.sbin/bsdconfig/startup/rcconf
==============================================================================
--- head/usr.sbin/bsdconfig/startup/rcconf	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/startup/rcconf	Sun Jun  2 09:02:12 2013	(r251244)
@@ -81,6 +81,7 @@ dialog_menu_main()
 {
 	local hline="$hline_arrows_tab_enter"
 	local prompt=""
+	local defaultitem= # Calculated below
 
 	RCCONF_MENU_LIST="
 		'X $msg_exit'    '$msg_exit_desc'
@@ -170,20 +171,23 @@ dialog_menu_main()
 		\"\$hline\"            \
 		$RCCONF_MENU_LIST
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
-		--title \"\$DIALOG_TITLE\"          \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--help-button                       \
-		--help-label \"\$msg_details\"      \
-		${SHOW_DESC:+--item-help}           \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$prompt\"                 \
-		$height $width $rows                \
-		$RCCONF_MENU_LIST                   \
+		--title \"\$DIALOG_TITLE\"         \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		--help-button                      \
+		--help-label \"\$msg_details\"     \
+		${SHOW_DESC:+--item-help}          \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
+		$RCCONF_MENU_LIST                  \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?
@@ -191,7 +195,7 @@ dialog_menu_main()
 	f_dialog_menutag_store "$menu_choice"
 
 	# Only update default-item on success
-	[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
+	[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
 
 	return $retval
 }

Modified: head/usr.sbin/bsdconfig/startup/rcdelete
==============================================================================
--- head/usr.sbin/bsdconfig/startup/rcdelete	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/startup/rcdelete	Sun Jun  2 09:02:12 2013	(r251244)
@@ -148,6 +148,7 @@ dialog_menu_main()
 {
 	local hline="$hline_arrows_tab_enter"
 	local prompt=""
+	local defaultitem= # Calculated below
 
 	#
 	# [Re-]Accent the menu list before incorporating it
@@ -205,21 +206,24 @@ dialog_menu_main()
 		\"\$hline\"            \
 		$menu_list
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
-		--title \"\$DIALOG_TITLE\"          \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--keep-tite                         \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--help-button                       \
-		--help-label \"\$msg_details\"      \
-		${SHOW_DESC:+--item-help}           \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$prompt\"                 \
-		$height $width $rows                \
-		$menu_list                          \
+		--title \"\$DIALOG_TITLE\"         \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--keep-tite                        \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		--help-button                      \
+		--help-label \"\$msg_details\"     \
+		${SHOW_DESC:+--item-help}          \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
+		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?
@@ -227,7 +231,7 @@ dialog_menu_main()
 	f_dialog_menutag_store "$menu_choice"
 
 	# Only update default-item on success
-	[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
+	[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
 
 	return $retval
 }

Modified: head/usr.sbin/bsdconfig/startup/rcvar
==============================================================================
--- head/usr.sbin/bsdconfig/startup/rcvar	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/startup/rcvar	Sun Jun  2 09:02:12 2013	(r251244)
@@ -67,6 +67,7 @@ dialog_menu_main()
 {
 	local hline="$hline_arrows_tab_enter"
 	local prompt=""
+	local defaultitem= # Calculated below
 
 	RCVAR_MENU_LIST="
 		'X $msg_exit' '$msg_exit_this_menu'
@@ -134,25 +135,28 @@ dialog_menu_main()
 		\"\$hline\"            \
 		$RCVAR_MENU_LIST
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
-		--title \"\$DIALOG_TITLE\"          \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--keep-tite                         \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		${SHOW_DESC:+--item-help}           \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$prompt\"                 \
-		$height $width $rows                \
-		$RCVAR_MENU_LIST                    \
+		--title \"\$DIALOG_TITLE\"         \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--keep-tite                        \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		${SHOW_DESC:+--item-help}          \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
+		$RCVAR_MENU_LIST                   \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?
 	f_dialog_data_sanitize menu_choice
 	f_dialog_menutag_store "$menu_choice"
-	setvar DEFAULTITEM_$$ "$menu_choice"
+	f_dialog_default_store "$menu_choice"
 	return $retval
 }
 

Modified: head/usr.sbin/bsdconfig/startup/startup
==============================================================================
--- head/usr.sbin/bsdconfig/startup/startup	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/startup/startup	Sun Jun  2 09:02:12 2013	(r251244)
@@ -51,6 +51,7 @@ dialog_menu_main()
 	local menu_list
 	local hline="$hline_arrows_tab_enter"
 	local prompt=""
+	local defaultitem= # Calculated below
 
 	menu_list="
 		'X' '$msg_exit'
@@ -67,23 +68,26 @@ dialog_menu_main()
 	                        \"\$hline\"            \
 	                        $menu_list
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
-		--title \"\$DIALOG_TITLE\"          \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$prompt\"                 \
-		$height $width $rows                \
-		$menu_list                          \
+		--title \"\$DIALOG_TITLE\"         \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\$prompt\"                \
+		$height $width $rows               \
+		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?
 	f_dialog_data_sanitize menu_choice
 	f_dialog_menutag_store "$menu_choice"
-	setvar DEFAULTITEM_$$ "$menu_choice"
+	f_dialog_default_store "$menu_choice"
 	return $retval
 }
 

Modified: head/usr.sbin/bsdconfig/timezone/timezone
==============================================================================
--- head/usr.sbin/bsdconfig/timezone/timezone	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/timezone/timezone	Sun Jun  2 09:02:12 2013	(r251244)
@@ -83,6 +83,7 @@ dialog_menu_main()
 	local title="$DIALOG_TITLE"
 	local btitle="$DIALOG_BACKTITLE"
 	local prompt="$msg_select_region"
+	local defaultitem= # Calculated below
 
 	local height width rows
 	eval f_dialog_menu_size height width rows \
@@ -92,22 +93,25 @@ dialog_menu_main()
 	                        \"\"         \
 	                        $continent_menu_list
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
-		--title \"\$title\"                 \
-		--backtitle \"\$btitle\"            \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$prompt\"                 \
-		$height $width $rows                \
-		$continent_menu_list                \
+		--title \"\$title\"              \
+		--backtitle \"\$btitle\"         \
+		--ok-label \"\$msg_ok\"          \
+		--cancel-label \"\$msg_cancel\"  \
+		--default-item \"\$defaultitem\" \
+		--menu \"\$prompt\"              \
+		$height $width $rows             \
+		$continent_menu_list             \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?
 	f_dialog_data_sanitize menu_choice
 	f_dialog_menutag_store "$menu_choice"
-	setvar DEFAULTITEM_$$ "$menu_choice"
+	f_dialog_default_store "$menu_choice"
 	return $retval
 }
 

Modified: head/usr.sbin/bsdconfig/usermgmt/groupinput
==============================================================================
--- head/usr.sbin/bsdconfig/usermgmt/groupinput	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/usermgmt/groupinput	Sun Jun  2 09:02:12 2013	(r251244)
@@ -228,21 +228,22 @@ while :; do
 	                        \"\$hline\"            \
 	                        $menu_items
 
+	f_dialog_default_fetch defaultitem
 	mtag=$( eval $DIALOG \
-		--title \"\$DIALOG_TITLE\"          \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$menu_text\"              \
-		$height $width $rows                \
-		$menu_items                         \
+		--title \"\$DIALOG_TITLE\"         \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\$menu_text\"             \
+		$height $width $rows               \
+		$menu_items                        \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	retval=$?
 	f_dialog_data_sanitize mtag
-	setvar DEFAULTITEM_$$ "$mtag"
+	f_dialog_default_store "$mtag"
 	f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
 
 	# Exit if user has either pressed ESC or chosen Cancel/No

Modified: head/usr.sbin/bsdconfig/usermgmt/userinput
==============================================================================
--- head/usr.sbin/bsdconfig/usermgmt/userinput	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/usermgmt/userinput	Sun Jun  2 09:02:12 2013	(r251244)
@@ -391,21 +391,22 @@ while :; do
 	                        \"\$hline\"            \
 	                        $menu_items
 
+	f_dialog_default_fetch defaultitem
 	mtag=$( eval $DIALOG \
-		--title \"\$DIALOG_TITLE\"          \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\$menu_text\"              \
-		$height $width $rows                \
-		$menu_items                         \
+		--title \"\$DIALOG_TITLE\"         \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\$menu_text\"             \
+		$height $width $rows               \
+		$menu_items                        \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	retval=$?
 	f_dialog_data_sanitize mtag
-	setvar DEFAULTITEM_$$ "$mtag"
+	f_dialog_default_store "$mtag"
 	f_dprintf "retval=%u mtag=[%s]" $retval "$mtag"
 
 	# Exit if user has either pressed ESC or chosen Cancel/No

Modified: head/usr.sbin/bsdconfig/usermgmt/usermgmt
==============================================================================
--- head/usr.sbin/bsdconfig/usermgmt/usermgmt	Sun Jun  2 05:57:45 2013	(r251243)
+++ head/usr.sbin/bsdconfig/usermgmt/usermgmt	Sun Jun  2 09:02:12 2013	(r251244)
@@ -53,6 +53,7 @@ dialog_menu_main()
 {
 	local menu_list
 	local hline="$hline_arrows_tab_enter"
+	local defaultitem= # Calculated below
 
 	menu_list="
 		'X' '$msg_exit'
@@ -76,20 +77,23 @@ dialog_menu_main()
 	# When using Xdialog(1) we need to bump the width for the buttons
 	[ "$USE_XDIALOG" ] && width=40
 
+	# Obtain default-item from previously stored selection
+	f_dialog_default_fetch defaultitem
+
 	local menu_choice
 	menu_choice=$( eval $DIALOG \
 		--title \"\$DIALOG_TITLE\"  \
-		--backtitle \"\$DIALOG_BACKTITLE\"  \
-		--hline \"\$hline\"                 \
-		--ok-label \"\$msg_ok\"             \
-		--cancel-label \"\$msg_cancel\"     \
-		--help-button                       \
-		--help-label \"\$msg_help\"         \
-		${USE_XDIALOG:+--help \"\"}         \
-		--default-item \"\$DEFAULTITEM_$$\" \
-		--menu \"\"                         \
-		$height $width $rows                \
-		$menu_list                          \
+		--backtitle \"\$DIALOG_BACKTITLE\" \
+		--hline \"\$hline\"                \
+		--ok-label \"\$msg_ok\"            \
+		--cancel-label \"\$msg_cancel\"    \
+		--help-button                      \
+		--help-label \"\$msg_help\"        \
+		${USE_XDIALOG:+--help \"\"}        \
+		--default-item \"\$defaultitem\"   \
+		--menu \"\"                        \
+		$height $width $rows               \
+		$menu_list                         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 	)
 	local retval=$?
@@ -97,7 +101,7 @@ dialog_menu_main()
 	f_dialog_menutag_store "$menu_choice"
 
 	# Only update default-item on success
-	[ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$menu_choice"
+	[ $retval -eq 0 ] && f_dialog_default_store "$menu_choice"
 
 	return $retval
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306020902.r5292CPU090179>