svn commit: r245402 - in head/usr.sbin/bsdconfig: networking/share share startup

Devin Teske dteske at FreeBSD.org
Mon Jan 14 01:15:27 UTC 2013


Author: dteske
Date: Mon Jan 14 01:15:25 2013
New Revision: 245402
URL: http://svnweb.freebsd.org/changeset/base/245402

Log:
  Add new f_yesno/f_noyes wrapper functions (which take printf(1) syntax).

Modified:
  head/usr.sbin/bsdconfig/networking/share/device.subr
  head/usr.sbin/bsdconfig/networking/share/hostname.subr
  head/usr.sbin/bsdconfig/networking/share/routing.subr
  head/usr.sbin/bsdconfig/share/common.subr
  head/usr.sbin/bsdconfig/startup/rcdelete

Modified: head/usr.sbin/bsdconfig/networking/share/device.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/device.subr	Mon Jan 14 01:09:23 2013	(r245401)
+++ head/usr.sbin/bsdconfig/networking/share/device.subr	Mon Jan 14 01:15:25 2013	(r245402)
@@ -456,9 +456,8 @@ f_dialog_menu_netdev_edit()
 	# Re/Apply the settings if desired
 	#
 	if [ ! "$dhcp" ]; then
-		f_dialog_yesno "Would you like to bring the $interface" \
-		               "interface up right now?"
-		if [ $? -eq $SUCCESS ]; then
+		if f_yesno "$msg_bring_interface_up" "$interface"
+		then
 			f_show_info "$msg_bring_interface_up" "$interface"
 
 			local dr="$( f_sysrc_get defaultrouter )" err

Modified: head/usr.sbin/bsdconfig/networking/share/hostname.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/hostname.subr	Mon Jan 14 01:09:23 2013	(r245401)
+++ head/usr.sbin/bsdconfig/networking/share/hostname.subr	Mon Jan 14 01:15:25 2013	(r245402)
@@ -201,10 +201,8 @@ f_dialog_input_hostname()
 			f_show_msg "$msg_activate_hostname_x11warning" \
 			           "$( hostname )" "$hostname"
 		else
-			f_dialog_yesno "$(
-				printf "$msg_activate_hostname" \
-				       "$( hostname )" "$hostname" \
-			)" \
+			f_yesno "$msg_activate_hostname" \
+			        "$( hostname )" "$hostname" \
 			&& hostname "$hostname"
 		fi
 	fi

Modified: head/usr.sbin/bsdconfig/networking/share/routing.subr
==============================================================================
--- head/usr.sbin/bsdconfig/networking/share/routing.subr	Mon Jan 14 01:09:23 2013	(r245401)
+++ head/usr.sbin/bsdconfig/networking/share/routing.subr	Mon Jan 14 01:15:25 2013	(r245402)
@@ -129,11 +129,8 @@ f_dialog_input_defaultrouter()
 	#
 	if [ "$( f_route_get_default )" != "$defaultrouter" ]; then
 		f_dialog_clear
-		f_dialog_yesno "$(
-			printf "$msg_activate_default_router" \
-			       "$( f_route_get_default )" "$defaultrouter"
-		)"
-
+		f_yesno "$msg_activate_default_router" \
+		        "$( f_route_get_default )" "$defaultrouter"
 		if [ $? -eq $SUCCESS ]; then
 			local err
 

Modified: head/usr.sbin/bsdconfig/share/common.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/common.subr	Mon Jan 14 01:09:23 2013	(r245401)
+++ head/usr.sbin/bsdconfig/share/common.subr	Mon Jan 14 01:15:25 2013	(r245402)
@@ -214,6 +214,50 @@ f_show_msg()
 	fi
 }
 
+
+# f_yesno $fmt [ $opts ... ]
+#
+# Display a message in a dialog yes/no box using printf(1) syntax.
+#
+f_yesno()
+{
+	local msg
+	msg=$( printf "$@" )
+
+	#
+	# Use f_dialog_yesno from dialog.subr if possible, otherwise fall
+	# back to dialog(1) (without options, making it obvious when using
+	# un-aided system dialog).
+	#
+	if f_have f_dialog_yesno; then
+		f_dialog_yesno "$msg"
+	else
+		dialog --yesno "$msg" 0 0
+	fi
+}
+
+# f_noyes $fmt [ $opts ... ]
+#
+# Display a message in a dialog yes/no box using printf(1) syntax.
+# NOTE: THis is just like the f_yesno function except "No" is default.
+#
+f_noyes()
+{
+	local msg
+	msg=$( printf "$@" )
+
+	#
+	# Use f_dialog_noyes from dialog.subr if possible, otherwise fall
+	# back to dialog(1) (without options, making it obvious when using
+	# un-aided system dialog).
+	#
+	if f_have f_dialog_noyes; then
+		f_dialog_noyes "$msg"
+	else
+		dialog --defaultno --yesno "$msg" 0 0
+	fi
+}
+
 # f_show_help $file
 #
 # Display a language help-file. Automatically takes $LANG and $LC_ALL into

Modified: head/usr.sbin/bsdconfig/startup/rcdelete
==============================================================================
--- head/usr.sbin/bsdconfig/startup/rcdelete	Mon Jan 14 01:09:23 2013	(r245401)
+++ head/usr.sbin/bsdconfig/startup/rcdelete	Mon Jan 14 01:15:25 2013	(r245402)
@@ -210,9 +210,7 @@ dialog_menu_delete()
 	[ $# -ge 1 ] || return $FAILURE
 
 	if [ $# -eq 1 ]; then
-		msg=$( printf "$msg_are_you_sure_you_want_to_delete" \
-		              "$delete_vars" )
-		f_dialog_noyes "$msg"
+		f_noyes "$msg_are_you_sure_you_want_to_delete" "$delete_vars"
 		return $?
 	fi
 


More information about the svn-src-all mailing list