svn commit: r257783 - in head/usr.sbin/bsdconfig: include share

Devin Teske dteske at FreeBSD.org
Thu Nov 7 10:23:38 UTC 2013


Author: dteske
Date: Thu Nov  7 10:23:37 2013
New Revision: 257783
URL: http://svnweb.freebsd.org/changeset/base/257783

Log:
  Add an f_show_err() function -- acts pretty much the same as f_show_msg()
  except it stylizes the msgbox widget to indicate an Error has occurred by
  setting an appropriate title and default message.

Modified:
  head/usr.sbin/bsdconfig/include/messages.subr
  head/usr.sbin/bsdconfig/share/common.subr

Modified: head/usr.sbin/bsdconfig/include/messages.subr
==============================================================================
--- head/usr.sbin/bsdconfig/include/messages.subr	Thu Nov  7 10:20:19 2013	(r257782)
+++ head/usr.sbin/bsdconfig/include/messages.subr	Thu Nov  7 10:23:37 2013	(r257783)
@@ -40,6 +40,7 @@ msg_afterstep_desc="Ports to support the
 msg_all="All"
 msg_all_desc="All available packages in all categories."
 msg_always_try_sudo_when_run_as="Always try sudo(8) when run as %s"
+msg_an_unknown_error_occurred="An unknown error occurred"
 msg_arabic_desc="Ported software for Arab countries."
 msg_archivers_desc="Utilities for archiving and unarchiving data."
 msg_armenia="Armenia"

Modified: head/usr.sbin/bsdconfig/share/common.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/common.subr	Thu Nov  7 10:20:19 2013	(r257782)
+++ head/usr.sbin/bsdconfig/share/common.subr	Thu Nov  7 10:23:37 2013	(r257783)
@@ -358,6 +358,30 @@ f_show_msg()
 	fi
 }
 
+# f_show_err $format [$arguments ...]
+#
+# Display a message in a dialog box with ``Error'' i18n title (overridden by
+# setting msg_error) using printf(1) syntax. If running non-interactively,
+# the process will terminate (using [above] f_die()).
+#
+f_show_err()
+{
+	[ "$nonInteractive" ] && f_die
+
+	local msg
+	msg=$( printf "$@" )
+
+	: ${msg:=${msg_an_unknown_error_occurred:-An unknown error occurred}}
+
+	if [ "$_DIALOG_SUBR" ]; then
+		f_dialog_title "${msg_error:-Error}"
+		f_dialog_msgbox "$msg"
+		f_dialog_title_restore
+	else
+		dialog --title "${msg_error:-Error}" --msgbox "$msg" 0 0
+	fi
+	return $SUCCESS
+}
 
 # f_yesno $format [$arguments ...]
 #


More information about the svn-src-all mailing list