diff options
author | dteske <dteske@FreeBSD.org> | 2013-01-14 01:15:25 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-01-14 01:15:25 +0000 |
commit | 45e98a4654e7a3deac741a3a873b469ed7a4749f (patch) | |
tree | 0f65dea73465a2671b9fc5fb0dcfa1af5f5397df /usr.sbin/bsdconfig/share | |
parent | 1e25b1497aa9e77e4c8fee7c7ea8d0fbc28960a4 (diff) | |
download | FreeBSD-src-45e98a4654e7a3deac741a3a873b469ed7a4749f.zip FreeBSD-src-45e98a4654e7a3deac741a3a873b469ed7a4749f.tar.gz |
Add new f_yesno/f_noyes wrapper functions (which take printf(1) syntax).
Diffstat (limited to 'usr.sbin/bsdconfig/share')
-rw-r--r-- | usr.sbin/bsdconfig/share/common.subr | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/usr.sbin/bsdconfig/share/common.subr b/usr.sbin/bsdconfig/share/common.subr index 05531aa..c66a54f 100644 --- a/usr.sbin/bsdconfig/share/common.subr +++ b/usr.sbin/bsdconfig/share/common.subr @@ -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 |