diff options
author | dteske <dteske@FreeBSD.org> | 2013-11-07 10:23:37 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-11-07 10:23:37 +0000 |
commit | 209f30e060c596ec0129b3699915813edecaf121 (patch) | |
tree | d108835be4387d3ef58e22eea868d566abe35731 | |
parent | 4bd843efbdbeff39eca31454eb34ecf56bd7388c (diff) | |
download | FreeBSD-src-209f30e060c596ec0129b3699915813edecaf121.zip FreeBSD-src-209f30e060c596ec0129b3699915813edecaf121.tar.gz |
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.
-rw-r--r-- | usr.sbin/bsdconfig/include/messages.subr | 1 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/share/common.subr | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/usr.sbin/bsdconfig/include/messages.subr b/usr.sbin/bsdconfig/include/messages.subr index 70b5c3d..bf78432 100644 --- a/usr.sbin/bsdconfig/include/messages.subr +++ b/usr.sbin/bsdconfig/include/messages.subr @@ -40,6 +40,7 @@ msg_afterstep_desc="Ports to support the AfterStep window manager." 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" diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr index 3817ca8..ed75b0a 100644 --- a/usr.sbin/bsdconfig/share/common.subr +++ b/usr.sbin/bsdconfig/share/common.subr @@ -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 ...] # |