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 | |
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).
-rw-r--r-- | usr.sbin/bsdconfig/networking/share/device.subr | 5 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/networking/share/hostname.subr | 6 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/networking/share/routing.subr | 7 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/share/common.subr | 44 | ||||
-rwxr-xr-x | usr.sbin/bsdconfig/startup/rcdelete | 4 |
5 files changed, 51 insertions, 15 deletions
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr index bf44768..23ac83b 100644 --- a/usr.sbin/bsdconfig/networking/share/device.subr +++ b/usr.sbin/bsdconfig/networking/share/device.subr @@ -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 diff --git a/usr.sbin/bsdconfig/networking/share/hostname.subr b/usr.sbin/bsdconfig/networking/share/hostname.subr index 959c7df..b276059 100644 --- a/usr.sbin/bsdconfig/networking/share/hostname.subr +++ b/usr.sbin/bsdconfig/networking/share/hostname.subr @@ -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 diff --git a/usr.sbin/bsdconfig/networking/share/routing.subr b/usr.sbin/bsdconfig/networking/share/routing.subr index 3990c03..4207ab2 100644 --- a/usr.sbin/bsdconfig/networking/share/routing.subr +++ b/usr.sbin/bsdconfig/networking/share/routing.subr @@ -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 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 diff --git a/usr.sbin/bsdconfig/startup/rcdelete b/usr.sbin/bsdconfig/startup/rcdelete index 02ec049..b0068f5 100755 --- a/usr.sbin/bsdconfig/startup/rcdelete +++ b/usr.sbin/bsdconfig/startup/rcdelete @@ -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 |