diff options
author | dteske <dteske@FreeBSD.org> | 2013-04-22 05:52:06 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-04-22 05:52:06 +0000 |
commit | 8f385d0e89111ca1716767f7dc0bdffe3225b3d0 (patch) | |
tree | cbdec6b0e95d9d7f693f2585627e66aaf3fa13ff /usr.sbin | |
parent | 2cbbbe9342ffd4b6a5fc07b551f747bfb7d8172c (diff) | |
download | FreeBSD-src-8f385d0e89111ca1716767f7dc0bdffe3225b3d0.zip FreeBSD-src-8f385d0e89111ca1716767f7dc0bdffe3225b3d0.tar.gz |
UI improvements. First, implement --default-item whenever and wherever
possible to save keystrokes. Second, overhaul startup/rcdelete for much
improved performance. Last, but not least, kill-off useage of --clear
and implement --keep-tite in harmony to minimize jarring transitions.
Also, fix local variable names where necessary while we're here with
other minor comment-enhancements/typo-corrections.
Diffstat (limited to 'usr.sbin')
42 files changed, 845 insertions, 343 deletions
diff --git a/usr.sbin/bsdconfig/bsdconfig b/usr.sbin/bsdconfig/bsdconfig index a6a9ee2..419d79f 100755 --- a/usr.sbin/bsdconfig/bsdconfig +++ b/usr.sbin/bsdconfig/bsdconfig @@ -197,11 +197,16 @@ dialog_menu_main() --help-button \ --help-label \"\$msg_help\" \ ${USE_XDIALOG:+--help \"\"} \ + --default-item \"\$DEFAULTITEM_$$\" \ --menu \"\$prompt\" $size $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" + + # Only update default-item on success + [ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu" + return $retval } diff --git a/usr.sbin/bsdconfig/console/console b/usr.sbin/bsdconfig/console/console index 2352559..e2387f5 100755 --- a/usr.sbin/bsdconfig/console/console +++ b/usr.sbin/bsdconfig/console/console @@ -71,16 +71,18 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\$prompt\" $size \ - $menu_list \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\$prompt\" $size \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" return $retval } diff --git a/usr.sbin/bsdconfig/console/font b/usr.sbin/bsdconfig/console/font index 763a94c..9363ffd 100755 --- a/usr.sbin/bsdconfig/console/font +++ b/usr.sbin/bsdconfig/console/font @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size defaultitem= local hline="$hline_choose_a_font" local prompt="$msg_font_menu_text" @@ -77,13 +77,31 @@ dialog_menu_main() \"\$hline\" \ $menu_list ) + case "$( f_sysrc_get font8x8 )" in + [Nn][Oo]|'') defaultitem="1 $msg_none";; + cp437-8x8) defaultitem="2 $msg_ibm_437";; + cp850-8x8) defaultitem="3 $msg_ibm_850";; + cp865-8x8) defaultitem="4 $msg_ibm_865";; + cp866-8x8) defaultitem="5 $msg_ibm_866";; + cp866u-8x8) defaultitem="6 $msg_ibm_866u";; + cp1251-8x8) defaultitem="7 $msg_ibm_1251";; + iso-8x8) defaultitem="8 $msg_iso_8859_1";; + iso02-8x8) defaultitem="9 $msg_iso_8859_2";; + iso04-8x8) defaultitem="a $msg_iso_8859_4";; + iso07-8x8) defaultitem="b $msg_iso_8859_7";; + iso08-8x8) defaultitem="c $msg_iso_8859_8";; + iso15-8x8) defaultitem="d $msg_iso_8859_15";; + swiss-8x8) defaultitem="e $msg_swiss";; + esac + local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD diff --git a/usr.sbin/bsdconfig/console/keymap b/usr.sbin/bsdconfig/console/keymap index f10b79e..e343db9 100755 --- a/usr.sbin/bsdconfig/console/keymap +++ b/usr.sbin/bsdconfig/console/keymap @@ -77,7 +77,7 @@ KEYMAP_NAMES=" # dialog_menu_main() { - local menu_list size + local menu_list size defaultitem= local hline="$hline_choose_a_keyboard_map" local prompt="$msg_keymap_menu_text" @@ -117,13 +117,89 @@ dialog_menu_main() \"\$hline\" \ $menu_list ) + case "$( f_sysrc_get keymap )" in + be.iso) defaultitem="$msg_belgian";; + br275.cp850) defaultitem="$msg_brazil_cp850";; + br275.iso) defaultitem="$msg_brazil_iso";; + br275.iso.acc) defaultitem="$msg_brazil_iso_accent";; + bg.bds.ctrlcaps) defaultitem="$msg_bulgarian_bds";; + bg.phonetic.ctrlcaps) defaultitem="$msg_bulgarian_phonetic";; + ce.iso2) defaultitem="$msg_central_european_iso";; + hr.iso) defaultitem="$msg_croatian_iso";; + cs.latin2.qwertz) defaultitem="$msg_czech_iso_accent";; + danish.cp865) defaultitem="$msg_danish_cp865";; + danish.iso) defaultitem="$msg_danish_iso";; + estonian.cp850) defaultitem="$msg_estonian_cp850";; + estonian.iso) defaultitem="$msg_estonian_iso";; + estonian.iso15) defaultitem="$msg_estonian_iso_15";; + finnish.cp850) defaultitem="$msg_finnish_cp850";; + finnish.iso) defaultitem="$msg_finnish_iso";; + fr.iso) defaultitem="$msg_french_iso";; + fr.iso.acc) defaultitem="$msg_french_iso_accent";; + fr.macbook.acc) defaultitem="$msg_french_iso_macbook";; + german.cp850) defaultitem="$msg_german_cp850";; + german.iso) defaultitem="$msg_german_iso";; + gr.us101.acc) defaultitem="$msg_greek_101";; + el.iso07) defaultitem="$msg_greek_104";; + gr.elot.acc) defaultitem="$msg_greek_elot";; + hu.iso2.101keys) defaultitem="$msg_hungarian_101";; + hu.iso2.102keys) defaultitem="$msg_hungarian_102";; + icelandic.iso) defaultitem="$msg_icelandic";; + icelandic.iso.acc) defaultitem="$msg_icelandic_accent";; + it.iso) defaultitem="$msg_italian";; + jp.106) defaultitem="$msg_japanese_106";; + latinamerican) defaultitem="$msg_latin_american";; + latinamerican.iso.acc) defaultitem="$msg_latin_american_accent";; + norwegian.iso) defaultitem="$msg_norway_iso";; + pl_PL.ISO8859-2) defaultitem="$msg_polish_iso";; + pt.iso) defaultitem="$msg_portuguese";; + pt.iso.acc) defaultitem="$msg_portuguese_accent";; + ru.koi8-r) defaultitem="$msg_russia_koi8_r";; + sk.iso2) defaultitem="$msg_slovak";; + si.iso) defaultitem="$msg_slovenian";; + spanish.iso) defaultitem="$msg_spanish";; + spanish.iso.acc) defaultitem="$msg_spanish_accent";; + swedish.cp850) defaultitem="$msg_swedish_cp850";; + swedish.iso) defaultitem="$msg_swedish_iso";; + swissfrench.cp850) defaultitem="$msg_swiss_french_cp850";; + swissfrench.iso) defaultitem="$msg_swiss_french_iso";; + swissfrench.iso.acc) defaultitem="$msg_swiss_french_iso_accent";; + swissgerman.cp850) defaultitem="$msg_swiss_german_cp850";; + swissgerman.iso) defaultitem="$msg_swiss_german_iso";; + swissgerman.iso.acc) defaultitem="$msg_swiss_german_iso_accent";; + uk.cp850) defaultitem="$msg_uk_cp850";; + uk.iso) defaultitem="$msg_uk_iso";; + ua.koi8-u) defaultitem="$msg_ukrainian_koi8_u";; + ua.koi8-u.shift.alt) defaultitem="$msg_ukrainian_koi8_u_koi8_r";; + us.pc-ctrl) defaultitem="$msg_usa_capslock_ctrl";; + us.dvorak) defaultitem="$msg_usa_dvorak";; + us.dvorakl) defaultitem="$msg_usa_dvorak_left";; + us.dvorakr) defaultitem="$msg_usa_dvorak_right";; + us.emacs) defaultitem="$msg_usa_emacs";; + us.iso) defaultitem="$msg_usa_iso";; + us.unix) defaultitem="$msg_usa_unix";; + esac + + # The defaultitem may have to be indented to match the menu_list + if [ "$defaultitem" ]; then + ( eval set -- $menu_list + while [ $# -gt 0 ]; do + [ "$defaultitem" = "$1" ] && break + [ " $defaultitem" = "$1" ] && exit 0 + shift 2 # tag/item + done + exit 1 # No modification needed + ) && defaultitem=" $defaultitem" + fi + local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD diff --git a/usr.sbin/bsdconfig/console/repeat b/usr.sbin/bsdconfig/console/repeat index face69e..b426d36 100755 --- a/usr.sbin/bsdconfig/console/repeat +++ b/usr.sbin/bsdconfig/console/repeat @@ -49,15 +49,15 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size defaultitem= local hline="$hline_choose_a_keyboard_repeat_rate" local prompt="$msg_repeat_menu_text" menu_list=" + '$msg_default' '$msg_default_desc' '$msg_slow' '$msg_slow_desc' '$msg_normal' '$msg_normal_desc' '$msg_fast' '$msg_fast_desc' - '$msg_default' '$msg_default_desc' " # END-QUOTE size=$( eval f_dialog_menu_size \ @@ -67,13 +67,21 @@ dialog_menu_main() \"\$hline\" \ $menu_list ) + case "$( f_sysrc_get keyrate )" in + slow) defaultitem="$msg_slow";; + normal) defaultitem="$msg_normal";; + fast) defaultitem="$msg_fast";; + [Nn][Oo]|'') defaultitem="$msg_default";; + esac + local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD diff --git a/usr.sbin/bsdconfig/console/saver b/usr.sbin/bsdconfig/console/saver index 1036b20..bea046e 100755 --- a/usr.sbin/bsdconfig/console/saver +++ b/usr.sbin/bsdconfig/console/saver @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size defaultitem= local hline="$hline_choose_a_screen_saver" local prompt="$msg_saver_menu_text" @@ -77,13 +77,30 @@ dialog_menu_main() \"\$hline\" \ $menu_list ) + case "$( f_sysrc_get saver )" in + blank) defaultitem="1 $msg_blank" ;; + beastie) defaultitem="2 $msg_beastie";; + daemon) defaultitem="3 $msg_daemon" ;; + dragon) defaultitem="4 $msg_dragon" ;; + fade) defaultitem="5 $msg_fade" ;; + fire) defaultitem="6 $msg_fire" ;; + green) defaultitem="7 $msg_green" ;; + logo) defaultitem="8 $msg_logo" ;; + rain) defaultitem="9 $msg_rain" ;; + snake) defaultitem="a $msg_snake" ;; + star) defaultitem="b $msg_star" ;; + warp) defaultitem="c $msg_warp" ;; + [Nn][Oo]|'') defaultitem="d $msg_none" ;; + esac + local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD diff --git a/usr.sbin/bsdconfig/console/screenmap b/usr.sbin/bsdconfig/console/screenmap index 27ce53c..17de356 100755 --- a/usr.sbin/bsdconfig/console/screenmap +++ b/usr.sbin/bsdconfig/console/screenmap @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size defaultitem= local hline="$hline_choose_a_screen_map" local prompt="$msg_screenmap_menu_text" @@ -69,13 +69,23 @@ dialog_menu_main() \"\$hline\" \ $menu_list ) + case "$( f_sysrc_get scrnmap )" in + [Nn][Oo]|'') defaultitem="1 $msg_none" ;; + iso-8859-1_to_cp437) defaultitem="2 $msg_iso_8859_1_to_ibm437" ;; + iso-8859-7_to_cp437) defaultitem="3 $msg_iso_8859_7_to_ibm437" ;; + us-ascii_to_cp437) defaultitem="4 $msg_us_ascii_to_ibm327" ;; + koi8-r2cp866) defaultitem="5 $msg_koi8_r_to_ibm866" ;; + koi8-u2cp866u) defaultitem="6 $msg_koi8_u_to_ibm866u" ;; + esac + local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD diff --git a/usr.sbin/bsdconfig/console/ttys b/usr.sbin/bsdconfig/console/ttys index e06a2a7..ad7a9c4 100755 --- a/usr.sbin/bsdconfig/console/ttys +++ b/usr.sbin/bsdconfig/console/ttys @@ -85,7 +85,7 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ diff --git a/usr.sbin/bsdconfig/mouse/mouse b/usr.sbin/bsdconfig/mouse/mouse index e8ce3d0..b1bd9d9 100755 --- a/usr.sbin/bsdconfig/mouse/mouse +++ b/usr.sbin/bsdconfig/mouse/mouse @@ -70,16 +70,18 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\$prompt\" $size \ - $menu_list \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\$prompt\" $size \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" return $retval } diff --git a/usr.sbin/bsdconfig/mouse/port b/usr.sbin/bsdconfig/mouse/port index 55c4eb7..cb40652 100755 --- a/usr.sbin/bsdconfig/mouse/port +++ b/usr.sbin/bsdconfig/mouse/port @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size defaultitem= local hline="" local prompt="$msg_port_menu_text" @@ -69,13 +69,23 @@ dialog_menu_main() \"\$hline\" \ $menu_list ) + case "$( f_sysrc_get moused_port )" in + /dev/psm0) defaultitem="1 $msg_ps2" ;; + /dev/cuau0) defaultitem="2 $msg_com1" ;; + /dev/cuau1) defaultitem="3 $msg_com2" ;; + /dev/cuau2) defaultitem="4 $msg_com3" ;; + /dev/cuau3) defaultitem="5 $msg_com4" ;; + /dev/mse0) defaultitem="6 $msg_busmouse" ;; + esac + local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD diff --git a/usr.sbin/bsdconfig/mouse/type b/usr.sbin/bsdconfig/mouse/type index 0bd0e06..f76e931 100755 --- a/usr.sbin/bsdconfig/mouse/type +++ b/usr.sbin/bsdconfig/mouse/type @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size defaultitem= local hline="" local prompt="$msg_protocol_menu_text" @@ -73,13 +73,27 @@ dialog_menu_main() \"\$hline\" \ $menu_list ) + case "$( f_sysrc_get moused_type )" in + auto) defaultitem="1 $msg_auto" ;; + glidepoint) defaultitem="2 $msg_glidepoint" ;; + mmhittab) defaultitem="3 $msg_hitachi" ;; + intellimouse) defaultitem="4 $msg_intellimouse" ;; + logitech) defaultitem="5 $msg_logitech" ;; + microsoft) defaultitem="6 $msg_microsoft" ;; + mmseries) defaultitem="7 $msg_mm_series" ;; + mouseman) defaultitem="8 $msg_mouseman" ;; + mousesystems) defaultitem="9 $msg_mousesystems" ;; + thinkingmouse) defaultitem="A $msg_thinkingmouse" ;; + esac + local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD diff --git a/usr.sbin/bsdconfig/networking/devices b/usr.sbin/bsdconfig/networking/devices index dd1fb37..7304a78 100755 --- a/usr.sbin/bsdconfig/networking/devices +++ b/usr.sbin/bsdconfig/networking/devices @@ -71,10 +71,12 @@ f_mustberoot_init # # Launch application main menu # +defaultitem="" while :; do - f_dialog_menu_netdev + f_dialog_menu_netdev "$defaultitem" retval=$? interface=$( f_dialog_menutag ) + defaultitem="$interface" [ $retval -eq 0 ] || break diff --git a/usr.sbin/bsdconfig/networking/hostname b/usr.sbin/bsdconfig/networking/hostname index ab74ae6..4029d3c 100755 --- a/usr.sbin/bsdconfig/networking/hostname +++ b/usr.sbin/bsdconfig/networking/hostname @@ -28,6 +28,9 @@ # ############################################################ INCLUDES +# Prevent device.subr (included indirectly) from auto scanning on load +DEVICE_SELF_SCAN_ALL=NO + BSDCFG_SHARE="/usr/share/bsdconfig" . $BSDCFG_SHARE/common.subr || exit 1 f_dprintf "%s: loading includes..." "$0" diff --git a/usr.sbin/bsdconfig/networking/networking b/usr.sbin/bsdconfig/networking/networking index d3c8a8d..3697f31 100755 --- a/usr.sbin/bsdconfig/networking/networking +++ b/usr.sbin/bsdconfig/networking/networking @@ -68,15 +68,17 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\" $size $menu_list \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\" $size $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" return $retval } diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr index cac8ef5..b47bfc9 100644 --- a/usr.sbin/bsdconfig/networking/share/device.subr +++ b/usr.sbin/bsdconfig/networking/share/device.subr @@ -55,12 +55,15 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr ############################################################ FUNCTIONS -# f_dialog_menu_netdev +# f_dialog_menu_netdev [$default] # -# Display a list of network devices with descriptions. +# Display a list of network devices with descriptions. Optionally, if present +# and non-NULL, initially highlight $default interface. # f_dialog_menu_netdev() { + local defaultitem="${1%\*}" # Tim trailing asterisk if present + # # Display a message to let the user know we're working... # (message will remain until we throw up the next dialog) @@ -125,6 +128,15 @@ f_dialog_menu_netdev() return $FAILURE fi + # + # Maybe the default item was marked as active + # + if [ "$defaultitem" ]; then + ifconfig "$defaultitem" 2> /dev/null | awk \ + '( $1 == "status:" && $2 != "active" ) { exit 0 }' || + defaultitem="$defaultitem*" + fi + local hline="$hline_arrows_tab_enter" # @@ -140,11 +152,12 @@ f_dialog_menu_netdev() $interfaces ) local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $interfaces \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD @@ -188,6 +201,7 @@ f_dialog_menu_netdev_edit() # changes effective because all three options must be specified at-once # to ifconfig(8). # + local defaultitem= while :; do local dhcp_status="$msg_disabled" [ "$dhcp" ] && dhcp_status="$msg_enabled" @@ -210,7 +224,7 @@ f_dialog_menu_netdev_edit() $menu_list ) local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ @@ -218,6 +232,7 @@ f_dialog_menu_netdev_edit() --help-button \ --help-label \"\$msg_help\" \ ${USE_XDIALOG:+--help \"\"} \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD @@ -234,6 +249,9 @@ f_dialog_menu_netdev_edit() elif [ $retval -ne $SUCCESS ]; then # "Cancel" was chosen (-1) or ESC was pressed (255) return $retval + else + # Only update default-item on success + defaultitem="$tag" fi # diff --git a/usr.sbin/bsdconfig/networking/share/media.subr b/usr.sbin/bsdconfig/networking/share/media.subr index eed8364a..e0e71e7 100644 --- a/usr.sbin/bsdconfig/networking/share/media.subr +++ b/usr.sbin/bsdconfig/networking/share/media.subr @@ -1,6 +1,6 @@ if [ ! "$_NETWORKING_MEDIA_SUBR" ]; then _NETWORKING_MEDIA_SUBR=1 # -# Copyright (c) 2006-2012 Devin Teske +# Copyright (c) 2006-2013 Devin Teske # All Rights Reserved. # # Redistribution and use in source and binary forms, with or without @@ -207,7 +207,7 @@ f_dialog_menu_media_options() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ diff --git a/usr.sbin/bsdconfig/networking/share/resolv.subr b/usr.sbin/bsdconfig/networking/share/resolv.subr index b525a4d..c37e719 100644 --- a/usr.sbin/bsdconfig/networking/share/resolv.subr +++ b/usr.sbin/bsdconfig/networking/share/resolv.subr @@ -396,7 +396,7 @@ f_dialog_menu_nameservers() local opt_exit="$msg_return_to_previous_menu" local opt_add="$msg_add_nameserver" local hline="$hline_arrows_tab_enter" - local prompt size + local prompt size defaultitem= # # Loop forever until the user has finished configuring nameservers @@ -435,11 +435,12 @@ f_dialog_menu_nameservers() $menu_list ) local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD @@ -450,7 +451,12 @@ f_dialog_menu_nameservers() local tag="$( f_dialog_menutag )" ns="" # Return if "Cancel" was chosen (-1) or ESC was pressed (255) - [ $retval -eq $SUCCESS ] || return $retval + if [ $retval -ne $SUCCESS ]; then + return $retval + else + # Only update default-item on success + defaultitem="$tag" + fi case "$tag" in "X $msg_exit") break;; diff --git a/usr.sbin/bsdconfig/password/include/messages.subr b/usr.sbin/bsdconfig/password/include/messages.subr index ac01ccc..655160d 100644 --- a/usr.sbin/bsdconfig/password/include/messages.subr +++ b/usr.sbin/bsdconfig/password/include/messages.subr @@ -1,4 +1,4 @@ -# Copyright (c) 2012 Devin Teske +# Copyright (c) 2012-2013 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -26,8 +26,8 @@ hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER" msg_cancel="Cancel" +msg_enter_new_password="Enter New Password" msg_ok="OK" -msg_password="Password" msg_password_changed="Password successfully changed." msg_password_is_empty="Password is empty." msg_passwords_do_not_match="Passwords do not match." diff --git a/usr.sbin/bsdconfig/password/share/password.subr b/usr.sbin/bsdconfig/password/share/password.subr index f4ebaab9..ba1f612 100644 --- a/usr.sbin/bsdconfig/password/share/password.subr +++ b/usr.sbin/bsdconfig/password/share/password.subr @@ -1,6 +1,6 @@ if [ ! "$_PASSWORD_PASSWORD_SUBR" ]; then _PASSWORD_PASSWORD_SUBR=1 # -# Copyright (c) 2012 Devin Teske +# Copyright (c) 2012-2013 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ f_dialog_input_password() local hline="$hline_alnum_punc_tab_enter" local msg size rmsg rsize - msg=$( printf "$msg_password" ) + msg=$( printf "$msg_enter_new_password" ) size=$( f_dialog_inputbox_size \ "$DIALOG_TITLE" \ "$DIALOG_BACKTITLE" \ diff --git a/usr.sbin/bsdconfig/security/kern_securelevel b/usr.sbin/bsdconfig/security/kern_securelevel index 5307bca..61ad9bf 100755 --- a/usr.sbin/bsdconfig/security/kern_securelevel +++ b/usr.sbin/bsdconfig/security/kern_securelevel @@ -51,12 +51,11 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size defaultitem= local hline="$hline_select_securelevel_to_operate_at" local prompt="$msg_securelevels_menu_text" menu_list=" - 'X $msg_exit' '$msg_exit_this_menu' '$msg_disabled' '$msg_disable_securelevels' '$msg_secure' '$msg_secure_mode' '$msg_highly_secure' '$msg_highly_secure_mode' @@ -70,9 +69,20 @@ dialog_menu_main() \"\$hline\" \ $menu_list ) + case "$( f_sysrc_get kern_securelevel_enable )" in + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) + case "$( f_sysrc_get kern_securelevel )" in + 1) defaultitem="$msg_secure" ;; + 2) defaultitem="$msg_highly_secure" ;; + 3) defaultitem="$msg_network_secure" ;; + esac ;; + *) + defaultitem="$msg_disabled" + esac + local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ @@ -80,6 +90,7 @@ dialog_menu_main() --help-button \ --help-label \"\$msg_help\" \ ${USE_XDIALOG:+--help \"\"} \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD diff --git a/usr.sbin/bsdconfig/security/security b/usr.sbin/bsdconfig/security/security index ff582ad..ba9f9e2 100755 --- a/usr.sbin/bsdconfig/security/security +++ b/usr.sbin/bsdconfig/security/security @@ -49,36 +49,53 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size mark=" " defaultitem= local hline="$hline_arrows_tab_enter" local prompt="$msg_menu_text" + # Obtain default-item (adjusted below for dynamic tags) + f_getvar DEFAULTITEM_$$ defaultitem + local ditem="${defaultitem%%[$IFS]*}" + menu_list=" 'X <<< $msg_exit' '$msg_exit_this_menu' " # END-QUOTE + # + # Add dynamically tagged entry for kern_securelevels + # case "$( f_sysrc_get kern_securelevel_enable )" in [Yy][Ee][Ss]) local kern_securelevel="$( f_sysrc_get kern_securelevel )" if [ ${#kern_securelevel} -eq 1 ] && - f_isinteger "$kern_securelevel" - then menu_list="$menu_list - '2 [$kern_securelevel] $msg_securelevel'" - else menu_list="$menu_list - '2 [X] $msg_securelevel'" - fi - menu_list="$menu_list '$msg_securelevel_desc'" - ;; - *) menu_list="$menu_list - '2 [ ] $msg_securelevel' '$msg_securelevel_desc'" + f_isinteger "$kern_securelevel" && + [ $kern_securelevel -lt 9 ] + then + mark="$kern_securelevel" + else + mark="X" + fi ;; + *) + mark=" " esac + menu_list="$menu_list + '2 [$mark] $msg_securelevel' '$msg_securelevel_desc'" + + # Update default-item if appropriate + [ "$ditem" = 2 ] && defaultitem="2 [$mark] $msg_securelevel" + # + # Add dynamically tagged entry for nfs_reserved_port_only + # case "$( f_sysrc_get nfs_reserved_port_only )" in - [Yy][Ee][Ss]) menu_list="$menu_list - '3 [X] $msg_nfs_port' '$msg_nfs_port_desc'";; - *) menu_list="$menu_list - '3 [ ] $msg_nfs_port' '$msg_nfs_port_desc'";; + [Yy][Ee][Ss]) mark="X" ;; + *) mark=" " ;; esac + menu_list="$menu_list + '3 [$mark] $msg_nfs_port' '$msg_nfs_port_desc'" + + # Update default-item if appropriate + [ "$ditem" = 3 ] && defaultitem="3 [$mark] $msg_nfs_port" size=$( eval f_dialog_menu_size \ \"\$DIALOG_TITLE\" \ @@ -89,17 +106,22 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" + + # Only update default-item on success + [ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu" + return $retval } diff --git a/usr.sbin/bsdconfig/share/media/options.subr b/usr.sbin/bsdconfig/share/media/options.subr index c32bec5..2c8d3bd 100644 --- a/usr.sbin/bsdconfig/share/media/options.subr +++ b/usr.sbin/bsdconfig/share/media/options.subr @@ -66,6 +66,7 @@ f_media_options_menu() unset $VAR_NONINTERACTIVE fi + local defaultitem= while :; do menu_list="" @@ -203,12 +204,14 @@ f_media_options_menu() --cancel-label \"\$msg_done\" \ --help-button \ --help-label \"\$msg_help\" \ + --default-item \"\$defaultitem\" \ ${USE_XDIALOG:+--help \"\"} \ --menu \"\$prompt\" $size $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" + defaultitem="$dialog_menu" local mtag mtag=$( f_dialog_menutag ) diff --git a/usr.sbin/bsdconfig/share/strings.subr b/usr.sbin/bsdconfig/share/strings.subr index 5b9f51e..73da04c 100644 --- a/usr.sbin/bsdconfig/share/strings.subr +++ b/usr.sbin/bsdconfig/share/strings.subr @@ -25,6 +25,21 @@ if [ ! "$_STRINGS_SUBR" ]; then _STRINGS_SUBR=1 # SUCH DAMAGE. # # $FreeBSD$ +# +############################################################ GLOBALS + +# +# Valid characters that can appear in an sh(1) variable name +# +# Please note that the character ranges A-Z and a-z should be avoided because +# these can include accent characters (which are not valid in a variable name). +# For example, A-Z matches any character that sorts after A but before Z, +# including A and Z. Although ASCII order would make more sense, that is not +# how it works. +# +VALID_VARNAME_CHARS="0-9ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_" + +############################################################ FUNCTIONS # f_substr "$string" $start [ $length ] # @@ -167,6 +182,90 @@ f_uridecode() fi } +# f_replaceall $string $find $replace [$var_to_set] +# +# Replace all occurrences of $find in $sting with $replace. If $var_to_set is +# either missing or NULL, the variable name is produced on standard out for +# capturing in a sub-shell (which is less recommended due to performance +# degradation). +# +f_replaceall() +{ + local __left="" __right="$1" + local __find="$2" __replace="$3" __var_to_set="$4" + while :; do + case "$__right" in *$__find*) + __left="$__left${__right%%$__find*}$__replace" + __right="${__right#*$__find}" + continue + esac + break + done + __left="$__left${__right#*$__find}" + if [ "$__var_to_set" ]; then + setvar "$__var_to_set" "$__left" + else + echo "$__left" + fi +} + +# f_str2varname $string [$var_to_set] +# +# Convert a string into a suitable value to be used as a variable name +# by converting unsuitable characters into the underscrore [_]. If $var_to_set +# is either missing or NULL, the variable name is produced on standard out for +# capturing in a sub-shell (which is less recommended due to performance +# degradation). +# +f_str2varname() +{ + local __string="$1" __var_to_set="$2" + f_replaceall "$__string" "[!$VALID_VARNAME_CHARS]" "_" "$__var_to_set" +} + +# f_shell_escape $string [$var_to_set] +# +# Escape $string for shell eval statement(s) by replacing all single-quotes +# with a special sequence that creates a compound string when interpolated +# by eval with surrounding single-quotes. +# +# For example: +# +# foo="abc'123" +# f_shell_escape "$foo" bar # bar=[abc'\''123] +# eval echo \'$foo\' # produces abc'123 +# +# This is helpful when processing an argument list that has to retain its +# escaped structure for later evaluations. +# +# WARNING: Surrounding single-quotes are not added; this is the responsibility +# of the code passing the escaped values to eval (which also aids readability). +# +f_shell_escape() +{ + local __string="$1" __var_to_set="$2" + f_replaceall "$__string" "'" "'\\''" "$__var_to_set" +} + +# f_shell_unescape $string [$var_to_set] +# +# The antithesis of f_shell_escape(), this function takes an escaped $string +# and expands it. +# +# For example: +# +# foo="abc'123" +# f_shell_escape "$foo" bar # bar=[abc'\''123] +# f_shell_unescape "$bar" # produces abc'123 +# +f_shell_unescape() +{ + local __string="$1" __var_to_set="$2" + f_replaceall "$__string" "'\\''" "'" "$__var_to_set" +} + +############################################################ MAIN + f_dprintf "%s: Successfully loaded." strings.subr fi # ! $_STRINGS_SUBR diff --git a/usr.sbin/bsdconfig/startup/misc b/usr.sbin/bsdconfig/startup/misc index 5a8c859..f0b5fb0 100755 --- a/usr.sbin/bsdconfig/startup/misc +++ b/usr.sbin/bsdconfig/startup/misc @@ -56,10 +56,14 @@ UNAME_P=$( uname -p ) # Processor Architecture (i.e. i386) # dialog_menu_main() { - local menu_list var_list size + local menu_list var_list size defaultitem= local hline="$hline_arrows_tab_enter" local prompt="$msg_miscellaneous_menu_text" + # Obtain default-item (adjusted below for dynamic tags) + f_getvar DEFAULTITEM_$$ defaultitem + local ditem="${defaultitem%%[$IFS]*}" + menu_list=" 'X <<< $msg_exit' '$msg_exit_this_menu' " # END-QUOTE @@ -84,7 +88,7 @@ dialog_menu_main() " # END-QUOTE fi - menu_list="$menu_list $( + eval "$( . "$RC_DEFAULTS" source_rc_confs export $var_list @@ -100,104 +104,132 @@ dialog_menu_main() export msg_sco msg_sco_desc export msg_svr4 msg_svr4_desc :| awk \ - -v uname_p="$UNAME_P" \ - -v menu_tags="$DIALOG_MENU_TAGS" \ - -v menu_fmt="'%c [%c] %s' '%s'\n" \ - -v sep_fmt="' ' ' -- '\n" \ - 'END { + -v uname_p="$UNAME_P" \ + -v menu_tags="$DIALOG_MENU_TAGS" \ + -v menu_fmt="'%s' '%s'\n" \ + -v mtag_fmt="%c [%c] %s" \ + -v separator="' ' ' -- '\n" \ + -v ditem="$ditem" \ + ' + function mprint(tag,item) + { + printf menu_fmt, tag, item + } + END { i = 1 + defaultitem = "" + + printf "menu_list=\"$menu_list\n" + if ( uname_p == "i386" ) { # # APM: Auto-power management services # (typically laptops) # - printf menu_fmt, substr(menu_tags, i++, 1), - ( ENVIRON["apm_enable"] ~ \ - /^[Yy][Ee][Ss]$/ ? "X" : " " ), - ENVIRON["msg_apm"], - ENVIRON["msg_apm_desc"] + char = substr(menu_tags, i++, 1) + mark = ( ENVIRON["apm_enable"] ~ \ + /^[Yy][Ee][Ss]$/ ? "X" : " " ) + subtag = ENVIRON["msg_apm"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_apm_desc"]) + if (ditem == char) defaultitem = tag } - # Separator - printf sep_fmt + printf separator # # Startup dirs: Set the list of dirs to look for # startup scripts # - printf menu_fmt, substr(menu_tags, i++, 1), - ( length(ENVIRON["local_startup"]) > 0 \ - ? "X" : " " ), - ENVIRON["msg_startup_dirs"], - ENVIRON["msg_startup_dirs_desc"] + char = substr(menu_tags, i++, 1) + mark = ( length(ENVIRON["local_startup"]) > 0 \ + ? "X" : " " ) + subtag = ENVIRON["msg_startup_dirs"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_startup_dirs_desc"]) + if (ditem == char) defaultitem = tag # # named: Run a local name server on this host # - printf menu_fmt, substr(menu_tags, i++, 1), - ( ENVIRON["named_enable"] ~ \ - /^[Yy][Ee][Ss]$/ ? "X" : " " ), - ENVIRON["msg_named"], - ENVIRON["msg_named_desc"] + char = substr(menu_tags, i++, 1) + mark = ( ENVIRON["named_enable"] ~ \ + /^[Yy][Ee][Ss]$/ ? "X" : " " ) + subtag = ENVIRON["msg_named"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_named_desc"]) + if (ditem == char) defaultitem = tag # # named flags: Set default flags to named (if enabled) # - printf menu_fmt, substr(menu_tags, i++, 1), - ( length(ENVIRON["named_flags"]) > 0 \ - ? "X" : " " ), - ENVIRON["msg_named_flags"], - ENVIRON["msg_named_flags_desc"] + char = substr(menu_tags, i++, 1) + mark = ( length(ENVIRON["named_flags"]) > 0 \ + ? "X" : " " ) + subtag = ENVIRON["msg_named_flags"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_named_flags_desc"]) + if (ditem == char) defaultitem = tag # # NIS client: This host wishes to be an NIS client. # - printf menu_fmt, substr(menu_tags, i++, 1), - ( ENVIRON["nis_client_enable"] ~ \ - /^[Yy][Ee][Ss]$/ ? "X" : " " ), - ENVIRON["msg_nis_client"], - ENVIRON["msg_nis_client_desc"] + char = substr(menu_tags, i++, 1) + mark = ( ENVIRON["nis_client_enable"] ~ \ + /^[Yy][Ee][Ss]$/ ? "X" : " " ) + subtag = ENVIRON["msg_nis_client"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_nis_client_desc"]) + if (ditem == char) defaultitem = tag # # NIS domainname: Set NIS domainname (if enabled) # - printf menu_fmt, substr(menu_tags, i++, 1), - ( length(ENVIRON["nisdomainname"]) > 0 \ - ? "X" : " " ), - ENVIRON["msg_nis_domainname"], - ENVIRON["msg_nis_domainname_desc"] + char = substr(menu_tags, i++, 1) + mark = ( length(ENVIRON["nisdomainname"]) > 0 && \ + ENVIRON["nisdomainname"] != "NO" \ + ? "X" : " " ) + subtag = ENVIRON["msg_nis_domainname"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_nis_domainname_desc"]) + if (ditem == char) defaultitem = tag # # NIS server: This host wishes to be an NIS server. # - printf menu_fmt, substr(menu_tags, i++, 1), - ( ENVIRON["nis_server_enable"] ~ \ - /^[Yy][Ee][Ss]$/ ? "X" : " " ), - ENVIRON["msg_nis_server"], - ENVIRON["msg_nis_server_desc"] + char = substr(menu_tags, i++, 1) + mark = ( ENVIRON["nis_server_enable"] ~ \ + /^[Yy][Ee][Ss]$/ ? "X" : " " ) + subtag = ENVIRON["msg_nis_server"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_nis_server_desc"]) + if (ditem == char) defaultitem = tag - # Separator - printf sep_fmt + printf separator # # Accounting: This host wishes to run process # accounting. # - printf menu_fmt, substr(menu_tags, i++, 1), - ( ENVIRON["accounting_enable"] ~ \ - /^[Yy][Ee][Ss]$/ ? "X" : " " ), - ENVIRON["msg_accounting"], - ENVIRON["msg_accounting_desc"] + char = substr(menu_tags, i++, 1) + mark = ( ENVIRON["accounting_enable"] ~ \ + /^[Yy][Ee][Ss]$/ ? "X" : " " ) + subtag = ENVIRON["msg_accounting"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_accounting_desc"]) + if (ditem == char) defaultitem = tag # # lpd: This host has a printer and wants to run lpd. # - printf menu_fmt, substr(menu_tags, i++, 1), - ( ENVIRON["lpd_enable"] ~ \ - /^[Yy][Ee][Ss]$/ ? "X" : " " ), - ENVIRON["msg_lpd"], - ENVIRON["msg_lpd_desc"] + char = substr(menu_tags, i++, 1) + mark = ( ENVIRON["lpd_enable"] ~ \ + /^[Yy][Ee][Ss]$/ ? "X" : " " ) + subtag = ENVIRON["msg_lpd"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_lpd_desc"]) + if (ditem == char) defaultitem = tag if ( uname_p == "i386" ) { @@ -205,22 +237,31 @@ dialog_menu_main() # SCO: This host wants to be able to run IBCS2 # binaries. # - printf menu_fmt, substr(menu_tags, i++, 1), - ( ENVIRON["ibcs2_enable"] ~ \ - /^[Yy][Ee][Ss]$/ ? "X" : " " ), - ENVIRON["msg_sco"], - ENVIRON["msg_sco_desc"] + char = substr(menu_tags, i++, 1) + mark = ( ENVIRON["ibcs2_enable"] ~ \ + /^[Yy][Ee][Ss]$/ ? "X" : " " ) + subtag = ENVIRON["msg_sco"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_sco_desc"]) + if (ditem == char) defaultitem = tag # # SVR4: This host wants to be able to run SVR4 # binaries. # - printf menu_fmt, substr(menu_tags, i++, 1), - ( ENVIRON["svr4_enable"] ~ \ - /^[Yy][Ee][Ss]$/ ? "X" : " " ), - ENVIRON["msg_svr4"], - ENVIRON["msg_svr4_desc"] + char = substr(menu_tags, i++, 1) + mark = ( ENVIRON["svr4_enable"] ~ \ + /^[Yy][Ee][Ss]$/ ? "X" : " " ) + subtag = ENVIRON["msg_svr4"] + tag = sprintf(mtag_fmt, char, mark, subtag) + mprint(tag, ENVIRON["msg_svr4_desc"]) + if (ditem == char) defaultitem = tag } + + printf "\"\n" + + if ( defaultitem ) + printf "defaultitem=\"%s\"\n", defaultitem }' )" @@ -233,16 +274,18 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" return $retval } diff --git a/usr.sbin/bsdconfig/startup/rcadd b/usr.sbin/bsdconfig/startup/rcadd index 0266149..a3c7724 100755 --- a/usr.sbin/bsdconfig/startup/rcadd +++ b/usr.sbin/bsdconfig/startup/rcadd @@ -75,7 +75,7 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ diff --git a/usr.sbin/bsdconfig/startup/rcconf b/usr.sbin/bsdconfig/startup/rcconf index 1fb01b0..45316d7 100755 --- a/usr.sbin/bsdconfig/startup/rcconf +++ b/usr.sbin/bsdconfig/startup/rcconf @@ -99,10 +99,10 @@ dialog_menu_main() if [ ! "$_RCCONF_MAP" ]; then # Genreate RCCONF_MAP of `var desc ...' per-line f_dialog_info "$msg_creating_rcconf_map" - RCCONF_MAP=$( f_startup_rcconf_map ) + f_startup_rcconf_map RCCONF_MAP export RCCONF_MAP # Generate _${var}_desc variables from $RCCONF_MAP - f_startup_rcconf_map_expand + f_startup_rcconf_map_expand RCCONF_MAP export _RCCONF_MAP=1 fi @@ -171,20 +171,25 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --help-button \ - --help-label \"\$msg_details\" \ - ${SHOW_DESC:+--item-help} \ - --menu \"\$prompt\" $size \ - $RCCONF_MENU_LIST \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --help-button \ + --help-label \"\$msg_details\" \ + ${SHOW_DESC:+--item-help} \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\$prompt\" $size \ + $RCCONF_MENU_LIST \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" + + # Only update default-item on success + [ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu" + return $retval } diff --git a/usr.sbin/bsdconfig/startup/rcdelete b/usr.sbin/bsdconfig/startup/rcdelete index 3e21658..c30ba29 100755 --- a/usr.sbin/bsdconfig/startup/rcdelete +++ b/usr.sbin/bsdconfig/startup/rcdelete @@ -48,7 +48,6 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # Global map/menu-list for the main menu # RCCONF_MAP= -_RCCONF_MAP= RCCONF_MENU_LIST= # @@ -73,46 +72,19 @@ fi ############################################################ FUNCTIONS -# dialog_menu_main +# dialog_create_main # -# Display the dialog(1)-based application main menu. +# Create the dialog(1) main menu. Separated from dialog_menu_main (used to +# display the menu) to speed up execution (we only call this function when +# initializing or changing the view details). # -dialog_menu_main() +dialog_create_main() { - local size - local hline="$hline_arrows_tab_enter" - local prompt="" - - RCCONF_MENU_LIST=" - 'X $msg_exit_cancel' '$msg_exit_cancel_desc' - ${SHOW_DESC:+'$msg_exit_cancel_help'} - '> $msg_delete_selected' '$msg_delete_selected_desc' - ${SHOW_DESC:+'$msg_delete_selected_help'} - '> $msg_all' '$msg_all_desc' - ${SHOW_DESC:+'$msg_all_help'} - '> $msg_none' '$msg_none_desc' - ${SHOW_DESC:+'$msg_none_help'} - ${USE_XDIALOG:+ - '> $msg_view_details' '$msg_view_details_desc' - ${SHOW_DESC:+'$msg_view_details_help'} - } - " # END-QUOTE - - if [ ! "$_RCCONF_MAP" ]; then - # Genreate RCCONF_MAP of `var desc ...' per-line - f_dialog_info "$msg_creating_rcconf_map" - RCCONF_MAP=$( f_startup_rcconf_map ) - export RCCONF_MAP - # Generate _${var}_desc variables from $RCCONF_MAP - f_startup_rcconf_map_expand - export _RCCONF_MAP=1 - fi - # Show infobox for modes that take a while to calculate/display [ "$SHOW_DEFAULT_VALUE" -o "$SHOW_CONFIGURED" ] && f_dialog_info "$msg_creating_menu_list" - RCCONF_MENU_LIST="$RCCONF_MENU_LIST $( + RCCONF_MENU_LIST=$( . "$RC_DEFAULTS" > /dev/null source_rc_confs > /dev/null var_list=$( f_startup_rcconf_list ) @@ -165,42 +137,105 @@ dialog_menu_main() } printf "\n" }' - )" + ) +} + +# dialog_menu_main +# +# Display the dialog(1)-based application main menu. +# +dialog_menu_main() +{ + local size + local hline="$hline_arrows_tab_enter" + local prompt="" + + # + # [Re-]Accent the menu list before incorporating it + # + local rcconf_var details help menu_buf delete + eval set -- $RCCONF_MENU_LIST + while [ $# -gt 0 ]; do + rcconf_var="$1" details="$2" delete= + f_shell_escape "$details" details + if [ "$SHOW_DESC" ]; then + help="$3" + f_shell_escape "$help" help + shift 3 # rcconf_var/details/help + else + shift 2 # rcconf_var/details + fi + + # Update mark + f_getvar _${rcconf_var# }_delete delete + if [ "$delete" ]; then + details="[X]${details#???}" + else + details="[ ]${details#???}" + fi + + # Update buffer with modified elements + menu_buf="$menu_buf + '$rcconf_var' '$details' ${SHOW_DESC:+'$help'}" # End-Quote + done + + local menu_list=" + 'X $msg_exit_cancel' '$msg_exit_cancel_desc' + ${SHOW_DESC:+'$msg_exit_cancel_help'} + '> $msg_delete_selected' '$msg_delete_selected_desc' + ${SHOW_DESC:+'$msg_delete_selected_help'} + '> $msg_all' '$msg_all_desc' + ${SHOW_DESC:+'$msg_all_help'} + '> $msg_none' '$msg_none_desc' + ${SHOW_DESC:+'$msg_none_help'} + ${USE_XDIALOG:+ + '> $msg_view_details' '$msg_view_details_desc' + ${SHOW_DESC:+'$msg_view_details_help'} + } + $menu_buf + " # END-QUOTE - set -f # noglob + set -f # noglob (descriptions in $RCCONF_MENU_LIST may contain *) size=$( eval f_dialog_menu_${SHOW_DESC:+with_help_}size \ \"\$DIALOG_TITLE\" \ \"\$DIALOG_BACKTITLE\" \ \"\$prompt\" \ \"\$hline\" \ - $RCCONF_MENU_LIST ) + $menu_list ) local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --help-button \ - --help-label \"\$msg_details\" \ - ${SHOW_DESC:+--item-help} \ - --menu \"\$prompt\" $size \ - $RCCONF_MENU_LIST \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --keep-tite \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --help-button \ + --help-label \"\$msg_details\" \ + ${SHOW_DESC:+--item-help} \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\$prompt\" $size \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" + + # Only update default-item on success + [ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu" + return $retval } -# dialog_menu_delete $var1 [$var2 ...] +# dialog_menu_confirm_delete $var1 [$var2 ...] # -# Get the user's blessing to delete one or more variables. -# if (and only-if) the user confirms (does not press ESC or Cancel/NO). +# Get the user's blessing to delete one or more variables. Returns success if +# (and only-if) the user confirms (does not press ESC or Cancel/NO). Does NOT +# return the user's menu-choice. # -dialog_menu_delete() +dialog_menu_confirm_delete() { local size local hline="$hline_arrows_tab_enter" @@ -244,9 +279,8 @@ dialog_menu_delete() local defaultno="defaultno" [ "$USE_XDIALOG" ] && defaultno="default-no" - local dialog_menu - dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + eval $DIALOG \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --$defaultno \ @@ -254,11 +288,7 @@ dialog_menu_delete() --cancel-label \"\$msg_cancel\" \ --menu \"\$prompt\" $size \ $menu_list \ - 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD - ) - local retval=$? - setvar DIALOG_MENU_$$ "$dialog_menu" - return $retval + 2> /dev/null } ############################################################ MAIN @@ -283,20 +313,29 @@ f_dialog_title "$msg_delete_startup_directives" f_dialog_backtitle "${ipgm:+bsdconfig }$pgm" f_mustberoot_init +# Genreate $RCCONF_MAP of `var desc ...' per-line (see share/rcconf.subr) +f_dialog_info "$msg_creating_rcconf_map" +f_startup_rcconf_map RCCONF_MAP + +# Generate _${var}_desc variables from $RCCONF_MAP +f_startup_rcconf_map_expand RCCONF_MAP + +# Generate RCCONF_MENU_LIST from $RCCONF_MAP +dialog_create_main + while :; do dialog_menu_main retval=$? mtag=$( f_dialog_menutag ) if [ "$USE_XDIALOG" ]; then - case "$mtag" in - "> $msg_view_details") - f_dialog_input_view_details + case "$mtag" in "> $msg_view_details") + f_dialog_input_view_details && dialog_create_main continue esac elif [ $retval -eq 2 ]; then # The ``Help'' button (labeled "Details") was pressed - f_dialog_input_view_details + f_dialog_input_view_details && dialog_create_main continue fi @@ -311,7 +350,7 @@ while :; do delete_vars="$delete_vars${delete_vars:+ }$var" done unset var # no longer needed - if dialog_menu_delete $delete_vars; then + if dialog_menu_confirm_delete $delete_vars; then f_dialog_title "$msg_info" f_dialog_info "$msg_deleting_selected_directives" f_dialog_title_restore @@ -323,6 +362,7 @@ while :; do fi done unset var # no longer needed + dialog_create_main fi ;; "> $msg_all") diff --git a/usr.sbin/bsdconfig/startup/rcvar b/usr.sbin/bsdconfig/startup/rcvar index 5ac41ef..d0268b8 100755 --- a/usr.sbin/bsdconfig/startup/rcvar +++ b/usr.sbin/bsdconfig/startup/rcvar @@ -135,17 +135,20 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - ${SHOW_DESC:+--item-help} \ - --menu \"\$prompt\" $size \ - $RCVAR_MENU_LIST \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --keep-tite \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + ${SHOW_DESC:+--item-help} \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\$prompt\" $size \ + $RCVAR_MENU_LIST \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" return $retval } diff --git a/usr.sbin/bsdconfig/startup/share/rcconf.subr b/usr.sbin/bsdconfig/startup/share/rcconf.subr index 12eafd9..0e1b889 100644 --- a/usr.sbin/bsdconfig/startup/share/rcconf.subr +++ b/usr.sbin/bsdconfig/startup/share/rcconf.subr @@ -1,6 +1,6 @@ if [ ! "$_STARTUP_RCCONF_SUBR" ]; then _STARTUP_RCCONF_SUBR=1 # -# Copyright (c) 2006-2012 Devin Teske +# Copyright (c) 2006-2013 Devin Teske # All Rights Reserved. # # Redistribution and use in source and binary forms, with or without @@ -88,7 +88,7 @@ f_startup_rcconf_list() ) } -# f_startup_rcconf_map +# f_startup_rcconf_map [$var_to_set] # # Produce a map (beit from in-memory cache or on-disk cache) of rc.conf(5) # variables and their descriptions. The map returned has the following format: @@ -100,11 +100,21 @@ f_startup_rcconf_list() # var the rc.conf(5) variable # description description of the variable # +# If $var_to_set is missing or NULL, the map is printed to standard output for +# capturing in a sub-shell (which is less-recommended because of performance +# degredation; for example, when called in a loop). +# f_startup_rcconf_map() { + local __var_to_set="$1" + # If the in-memory cached value is available, return it immediately if [ "$_STARTUP_RCCONF_MAP" ]; then - echo "$STARTUP_RCCONF_MAP" + if [ "$__var_to_set" ]; then + setvar "$__var_to_set" "$STARTUP_RCCONF_MAP" + else + echo "$STARTUP_RCCONF_MAP" + fi return $SUCCESS fi @@ -117,8 +127,8 @@ f_startup_rcconf_map() # cache file (containing this digest on the first line) is valid and # can be used to quickly populate the cache value for immediate return. # - local rc_defaults_digest - rc_defaults_digest=$( md5 < "$RC_DEFAULTS" ) + local __rc_defaults_digest + __rc_defaults_digest=$( md5 < "$RC_DEFAULTS" ) # # Check to see if the global persistant cache file exists @@ -138,7 +148,8 @@ f_startup_rcconf_map() # one populate the in-memory cache from the on- # disk cache and provide success exit status. # - if [ "$digest" = "$rc_defaults_digest" ]; then + if [ "$digest" = "$__rc_defaults_digest" ] + then cat exit $SUCCESS else @@ -148,10 +159,15 @@ f_startup_rcconf_map() fi ) < "$STARTUP_RCCONF_MAP_CACHEFILE" ) - export STARTUP_RCCONF_MAP - if [ $? -eq $SUCCESS ]; then + local __retval=$? + export STARTUP_RCCONF_MAP # Make children faster (export cache) + if [ $__retval -eq $SUCCESS ]; then export _STARTUP_RCCONF_MAP=1 - echo "$STARTUP_RCCONF_MAP" + if [ "$__var_to_set" ]; then + setvar "$__var_to_set" "$STARTUP_RCCONF_MAP" + else + echo "$STARTUP_RCCONF_MAP" + fi return $SUCCESS fi # Otherwise, fall-thru to create in-memory cache from scratch @@ -198,23 +214,23 @@ f_startup_rcconf_map() # # Create a new temporary file to write to - local tmpfile="$( mktemp -t "$pgm" )" - [ "$tmpfile" ] || return $FAILURE + local __tmpfile="$( mktemp -t "$pgm" )" + [ "$__tmpfile" ] || return $FAILURE # Write the temporary file contents - echo "$rc_defaults_digest" > "$tmpfile" - echo "$STARTUP_RCCONF_MAP" >> "$tmpfile" + echo "$__rc_defaults_digest" > "$__tmpfile" + echo "$STARTUP_RCCONF_MAP" >> "$__tmpfile" # Finally, move the temporary file into place case "$STARTUP_RCCONF_MAP_CACHEFILE" in */*) f_quietly mkdir -p "${STARTUP_RCCONF_MAP_CACHEFILE%/*}" esac - mv "$tmpfile" "$STARTUP_RCCONF_MAP_CACHEFILE" + mv "$__tmpfile" "$STARTUP_RCCONF_MAP_CACHEFILE" } -# f_startup_rcconf_map_expand +# f_startup_rcconf_map_expand $var_to_get # -# Expands the map ($RCCONF_MAP) into the shell environment namespace by +# Expands the map ($var_to_get) into the shell environment namespace by # creating _${var}_desc variables containing the description of each variable # encountered. # @@ -222,7 +238,8 @@ f_startup_rcconf_map() # f_startup_rcconf_map_expand() { - eval "$( echo "$RCCONF_MAP" | awk ' + local var_to_get="$1" + eval "$( f_getvar "$var_to_get" | awk ' BEGIN { rword = "^[[:space:]]*[^[:space:]]*[[:space:]]*" } @@ -246,12 +263,13 @@ f_startup_rcconf_map_expand() # Mutually exclusive options: # # SHOW_VALUE Show the value (default; override only) -# SHOW_VALUE_DEFAULT Show both value and default +# SHOW_DEFAULT_VALUE Show both value and default # SHOW_CONFIGURED Show rc.conf(5) file variable is configured in # # Each variable is treated as a boolean (NULL for false, non-NULL for true). # -# Variables are exported for later-required awk(1) ENVIRON visibility. +# Variables are exported for later-required awk(1) ENVIRON visibility. Returns +# success unless the user chose `Cancel' or pressed Escape. # f_dialog_input_view_details() { @@ -259,14 +277,23 @@ f_dialog_input_view_details() local hline="$hline_arrows_tab_enter" local prompt="" - local md=" " m1=" " m2=" " m3=" " - [ "$SHOW_DESC" ] && md="X" - [ "$SHOW_VALUE" ] && m1="*" - [ "$SHOW_DEFAULT_VALUE" ] && m2="*" - [ "$SHOW_CONFIGURED" ] && m3="*" + local md=" " + if [ "$SHOW_DESC" ]; then + md="X" + fi + local m1=" " m2=" " m3=" " defaultitem= + if [ "$SHOW_VALUE" ]; then + m1="*" + defaultitem="1 ($m1) $msg_show_value" + elif [ "$SHOW_DEFAULT_VALUE" ]; then + m2="*" + defaultitem="2 ($m2) $msg_show_default_value" + elif [ "$SHOW_CONFIGURED" ]; then + m3="*" + defaultitem="3 ($m3) $msg_show_configured" + fi menu_list=" - 'X $msg_exit' '$msg_exit_this_menu' 'R $msg_reset' '$msg_reset_desc' 'D [$md] $msg_desc' '$msg_desc_desc' '1 ($m1) $msg_show_value' '$msg_show_value_desc' @@ -290,6 +317,7 @@ f_dialog_input_view_details() --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD @@ -301,8 +329,7 @@ f_dialog_input_view_details() f_dialog_title_restore - [ $retval -eq 0 ] || return $SUCCESS - [ "$mtag" = "X $msg_exit" ] && return $SUCCESS + [ $retval -eq 0 ] || return $FAILURE case "$mtag" in "R $msg_reset") diff --git a/usr.sbin/bsdconfig/startup/share/rcvar.subr b/usr.sbin/bsdconfig/startup/share/rcvar.subr index 702c5e9..2146495 100644 --- a/usr.sbin/bsdconfig/startup/share/rcvar.subr +++ b/usr.sbin/bsdconfig/startup/share/rcvar.subr @@ -1,6 +1,6 @@ if [ ! "$_STARTUP_RCVAR_SUBR" ]; then _STARTUP_RCVAR_SUBR=1 # -# Copyright (c) 2006-2012 Devin Teske +# Copyright (c) 2006-2013 Devin Teske # All Rights Reserved. # # Redistribution and use in source and binary forms, with or without @@ -65,7 +65,7 @@ STARTUP_RCVAR_MAP_CACHEFILE="/var/run/bsdconfig/startup_rcvar_map.cache" ############################################################ FUNCTIONS -# f_startup_rcvar_map +# f_startup_rcvar_map [$var_to_set] # # Produce a map (beit from in-memory cache or on-disk cache) of rc.d scripts # and their associated rcvar's. The map returned has the following format: @@ -79,11 +79,21 @@ STARTUP_RCVAR_MAP_CACHEFILE="/var/run/bsdconfig/startup_rcvar_map.cache" # script the rc.d script in-question # description description of the variable from rc.conf(5) defaults # +# If $var_to_set is missing or NULL, the map is printed to standard output for +# capturing in a sub-shell (which is less-recommended because of performance +# degredation; for example, when called in a loop). +# f_startup_rcvar_map() { + local __var_to_set="$1" + # If the in-memory cached value is available, return it immediately if [ "$_STARTUP_RCVAR_MAP" ]; then - echo "$STARTUP_RCVAR_MAP" + if [ "$__var_to_set" ]; then + setvar "$__var_to_set" "$STARTUP_RCVAR_MAP" + else + echo "$STARTUP_RCVAR_MAP" + fi return $SUCCESS fi @@ -92,19 +102,20 @@ f_startup_rcvar_map() # # Get a list of /etc/rc.d scripts ... - local file rc_script_list= - for file in "$ETC_RC_D"/*; do - [ -f "$file" ] || continue - [ -x "$file" ] || continue - rc_script_list="$rc_script_list${rc_script_list:+ }$file" + local __file __rc_script_list= + for __file in "$ETC_RC_D"/*; do + [ -f "$__file" ] || continue + [ -x "$__file" ] || continue + __rc_script_list="$__rc_script_list $__file" done # ... and /usr/local/etc/rc.d scripts - rc_script_list="$rc_script_list${rc_script_list:+ }$( + __rc_script_list="$__rc_script_list $( local_startup=$( f_sysrc_get local_startup ) f_include "$ETC_RC_SUBR" find_local_scripts_new echo $local_rc )" + __rc_script_list="${__rc_script_list# }" # Trim leading space # # Calculate a digest given the checksums of all dependencies (scripts @@ -113,9 +124,9 @@ f_startup_rcvar_map() # first line) is valid and can be used to quickly populate the cache # value for immediate return. # - local rc_script_list_digest - rc_script_list_digest=$( cd "$ETC_RC_D" && - cksum "$RC_DEFAULTS" $rc_script_list | md5 ) + local __rc_script_list_digest + __rc_script_list_digest=$( cd "$ETC_RC_D" && + cksum "$RC_DEFAULTS" $__rc_script_list | md5 ) # # Check to see if the global persistant cache file exists @@ -123,19 +134,19 @@ f_startup_rcvar_map() if [ -f "$STARTUP_RCVAR_MAP_CACHEFILE" ]; then # # Attempt to populate the in-memory cache with the (soon to be) - # be validated on-disk cache. If validation fails, fall-back to - # the current value and provide error exit status. + # validated on-disk cache. If validation fails, fall-back to + # the current value and return error. # STARTUP_RCVAR_MAP=$( - ( # Get digest as the first word on the first line + ( # Get digest as first word on first line read digest rest_ignored # # If the stored digest matches the calculated- # one populate the in-memory cache from the on- - # disk cache and provide success exit status. + # disk cache and return success. # - if [ "$digest" = "$rc_script_list_digest" ] + if [ "$digest" = "$__rc_script_list_digest" ] then cat exit $SUCCESS @@ -146,10 +157,15 @@ f_startup_rcvar_map() fi ) < "$STARTUP_RCVAR_MAP_CACHEFILE" ) - export STARTUP_RCVAR_MAP - if [ $? -eq $SUCCESS ]; then + local __retval=$? + export STARTUP_RCVAR_MAP # Make children faster (export cache) + if [ $__retval -eq $SUCCESS ]; then export _STARTUP_RCVAR_MAP=1 - echo "$STARTUP_RCVAR_MAP" + if [ "$__var_to_set" ]; then + setvar "$__var_to_set" "$STARTUP_RCVAR_MAP" + else + echo "$STARTUP_RCVAR_MAP" + fi return $SUCCESS fi # Otherwise, fall-thru to create in-memory cache from scratch @@ -162,7 +178,7 @@ f_startup_rcvar_map() # STARTUP_RCVAR_MAP=$( - for script in $rc_script_list; do + for script in $__rc_script_list; do rcvar_list=$( $script rcvar | awk -F= \ -v script="$script" ' /^'"$STARTUP_RCVAR_REGEX"'/ { @@ -184,25 +200,29 @@ f_startup_rcvar_map() ) export STARTUP_RCVAR_MAP export _STARTUP_RCVAR_MAP=1 - echo "$STARTUP_RCVAR_MAP" + if [ "$__var_to_set" ]; then + setvar "$__var_to_set" "$STARTUP_RCVAR_MAP" + else + echo "$STARTUP_RCVAR_MAP" + fi # - # Attempt to create the persistant global cache + # Attempt to create/update the persistant global cache # # Create a new temporary file to write to - local tmpfile="$( mktemp -t "$pgm" )" - [ "$tmpfile" ] || return $FAILURE + local __tmpfile="$( mktemp -t "$pgm" )" + [ "$__tmpfile" ] || return $FAILURE # Write the temporary file contents - echo "$rc_script_list_digest" > "$tmpfile" - echo "$STARTUP_RCVAR_MAP" >> "$tmpfile" + echo "$__rc_script_list_digest" > "$__tmpfile" + echo "$STARTUP_RCVAR_MAP" >> "$__tmpfile" # Finally, move the temporary file into place case "$STARTUP_RCVAR_MAP_CACHEFILE" in */*) f_quietly mkdir -p "${STARTUP_RCVAR_MAP_CACHEFILE%/*}" esac - mv "$tmpfile" "$STARTUP_RCVAR_MAP_CACHEFILE" + mv "$__tmpfile" "$STARTUP_RCVAR_MAP_CACHEFILE" } ############################################################ MAIN diff --git a/usr.sbin/bsdconfig/startup/startup b/usr.sbin/bsdconfig/startup/startup index 331989c..45375fe 100755 --- a/usr.sbin/bsdconfig/startup/startup +++ b/usr.sbin/bsdconfig/startup/startup @@ -68,16 +68,18 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\$prompt\" $size \ - $menu_list \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\$prompt\" $size \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" return $retval } diff --git a/usr.sbin/bsdconfig/timezone/timezone b/usr.sbin/bsdconfig/timezone/timezone index c232344..62dc7f7 100755 --- a/usr.sbin/bsdconfig/timezone/timezone +++ b/usr.sbin/bsdconfig/timezone/timezone @@ -94,15 +94,17 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --title \"\$title\" \ - --backtitle \"\$btitle\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\$prompt\" $size \ - $continent_menu_list \ + --title \"\$title\" \ + --backtitle \"\$btitle\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\$prompt\" $size \ + $continent_menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" return $retval } @@ -285,6 +287,8 @@ f_make_menus # creates $continent_menu_list and $continent_*_menu_list # # Launch application main menu # +defaultctry="" +defaultzone="" NEED_CONTINENT=1 NEED_COUNTRY=1 while :; do @@ -360,17 +364,19 @@ while :; do # Launch the country selection menu # dialog_menu=$( eval $DIALOG \ - --title \"\$title\" \ - --backtitle \"\$btitle\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\$prompt\" $size \ - $menu_list \ + --title \"\$title\" \ + --backtitle \"\$btitle\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultctry\" \ + --menu \"\$prompt\" $size \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" tag=$( f_dialog_menutag ) + defaultctry="$tag" if [ $retval -ne 0 ]; then NEED_CONTINENT=1 @@ -417,17 +423,19 @@ while :; do # NOTE: This is as deep as we go # dialog_menu=$( eval $DIALOG \ - --title \"\$title\" \ - --backtitle \"\$btitle\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\$prompt\" $size \ - $menu_list \ + --title \"\$title\" \ + --backtitle \"\$btitle\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultzone\" \ + --menu \"\$prompt\" $size \ + $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" n=$( f_dialog_menutag ) + defaultzone="$n" if [ $retval -ne 0 ]; then [ $nitems -eq 1 ] && NEED_CONTINENT=1 diff --git a/usr.sbin/bsdconfig/usermgmt/groupdel b/usr.sbin/bsdconfig/usermgmt/groupdel index 38fe311..ff6b702 100755 --- a/usr.sbin/bsdconfig/usermgmt/groupdel +++ b/usr.sbin/bsdconfig/usermgmt/groupdel @@ -67,11 +67,13 @@ f_mustberoot_init # # Loop until the user Exits, Cancels or presses ESC # +defaultitem="" while :; do - f_dialog_menu_group_list + f_dialog_menu_group_list "$defaultitem" retval=$? mtag=$( f_dialog_menutag ) f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" + defaultitem="$mtag" [ $retval -eq 0 ] || f_die diff --git a/usr.sbin/bsdconfig/usermgmt/groupedit b/usr.sbin/bsdconfig/usermgmt/groupedit index 93036e1..7cd70c6 100755 --- a/usr.sbin/bsdconfig/usermgmt/groupedit +++ b/usr.sbin/bsdconfig/usermgmt/groupedit @@ -67,11 +67,13 @@ f_mustberoot_init # # Loop until the user Exits, Cancels or presses ESC # +defaultitem="" while :; do - f_dialog_menu_group_list + f_dialog_menu_group_list "$defaultitem" retval=$? mtag=$( f_dialog_menutag ) f_dprintf "retval=%s mtag=[%s]" $retval "$mtag" + defaultitem="$mtag" [ $retval -eq 0 ] || f_die diff --git a/usr.sbin/bsdconfig/usermgmt/groupinput b/usr.sbin/bsdconfig/usermgmt/groupinput index c459224..a307a93 100755 --- a/usr.sbin/bsdconfig/usermgmt/groupinput +++ b/usr.sbin/bsdconfig/usermgmt/groupinput @@ -1,7 +1,7 @@ #!/bin/sh #- # Copyright (c) 2012 Ron McDowell -# Copyright (c) 2012 Devin Teske +# Copyright (c) 2012-2013 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -229,17 +229,19 @@ while :; do $menu_items ) dialog_menu=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\$menu_text\" $size \ - $menu_items \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\$menu_text\" $size \ + $menu_items \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" mtag=$( f_dialog_menutag ) f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" @@ -258,7 +260,7 @@ while :; do case "$mode" in Add) f_dialog_input_group_name "$group_name" ;; Edit/View|Delete) - f_dialog_menu_group_list + f_dialog_menu_group_list "$group_name" retval=$? mtag=$( f_dialog_menutag ) f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" diff --git a/usr.sbin/bsdconfig/usermgmt/include/messages.subr b/usr.sbin/bsdconfig/usermgmt/include/messages.subr index e2e7bf3..24d7a95 100644 --- a/usr.sbin/bsdconfig/usermgmt/include/messages.subr +++ b/usr.sbin/bsdconfig/usermgmt/include/messages.subr @@ -1,5 +1,5 @@ # Copyright (c) 2012 Ron McDowell -# Copyright (c) 2012 Devin Teske +# Copyright (c) 2012-2013 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -26,6 +26,7 @@ # $FreeBSD$ hline_alnum_punc_tab_enter="Use alpha-numeric, punctuation, TAB or ENTER" +hline_alnum_space_tab_enter="Use alpha-numeric, SPACE, TAB or ENTER" hline_alnum_tab_enter="Use alpha-numeric, TAB or ENTER" hline_arrows_space_tab_enter="Use arrows, SPACE, TAB or ENTER" hline_arrows_tab_enter="Press arrows, TAB or ENTER" diff --git a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr index 278e0a4..78b5f80 100644 --- a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr +++ b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr @@ -1,7 +1,7 @@ if [ ! "$_USERMGMT_GROUP_INPUT_SUBR" ]; then _USERMGMT_GROUP_INPUT_SUBR=1 # # Copyright (c) 2012 Ron McDowell -# Copyright (c) 2012 Devin Teske +# Copyright (c) 2012-2013 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -58,12 +58,14 @@ f_input_group() }' ) } -# f_dialog_menu_group_list +# f_dialog_menu_group_list [$default] # -# Allows the user to select a group from a list. +# Allows the user to select a group from a list. Optionally, if present and +# non-NULL, initially highlight $default group. # f_dialog_menu_group_list() { + local defaultitem="$1" local menu_list size local hline="$hline_alnum_punc_tab_enter" @@ -87,11 +89,12 @@ f_dialog_menu_group_list() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\" $size $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) @@ -299,7 +302,7 @@ f_dialog_input_group_members() '2' '$msg_enter_group_members_manually' " # END-QUOTE - local dialog_menu + local dialog_menu defaultitem= while :; do msg="$msg_group_members:" menu_size=$( eval f_dialog_menu_size \ @@ -314,12 +317,14 @@ f_dialog_input_group_members() --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$msg\" $menu_size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" + defaultitem="$dialog_menu" menu_choice=$( f_dialog_menutag ) f_dprintf "retval=%u menu_choice=[%s]" $retval "$menu_choice" diff --git a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr index e0281ed..db2c819 100644 --- a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr +++ b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr @@ -1,7 +1,7 @@ if [ ! "$_USERMGMT_USER_INPUT_SUBR" ]; then _USERMGMT_USER_INPUT_SUBR=1 # # Copyright (c) 2012 Ron McDowell -# Copyright (c) 2012 Devin Teske +# Copyright (c) 2012-2013 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -83,12 +83,14 @@ f_input_user() pw_member_groups=$( f_get_member_groups "$user" ) } -# f_dialog_menu_user_list +# f_dialog_menu_user_list [$default] # -# Allows the user to select a login from a list. +# Allows the user to select a login from a list. Optionally, if present and +# non-NULL, initially highlight $default user. # f_dialog_menu_user_list() { + local defaultitem="$1" local menu_list size local hline="$hline_alnum_punc_tab_enter" @@ -112,11 +114,12 @@ f_dialog_menu_user_list() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\" $size $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) @@ -134,7 +137,7 @@ f_dialog_menu_user_list() f_dialog_input_member_groups() { local msg="$( printf "$msg_member_of_groups" )" - local hline="$hline_alnum_tab_enter" + local hline="$hline_alnum_space_tab_enter" # # Loop until the user provides taint-free/valid input diff --git a/usr.sbin/bsdconfig/usermgmt/userdel b/usr.sbin/bsdconfig/usermgmt/userdel index 02f6e65..3847a1a 100755 --- a/usr.sbin/bsdconfig/usermgmt/userdel +++ b/usr.sbin/bsdconfig/usermgmt/userdel @@ -67,11 +67,13 @@ f_mustberoot_init # # Loop until the user Exits, Cancels or presses ESC # +defaultitem="" while :; do - f_dialog_menu_user_list + f_dialog_menu_user_list "$defaultitem" retval=$? mtag=$( f_dialog_menutag ) f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" + defaultitem="$mtag" [ $retval -eq 0 ] || f_die diff --git a/usr.sbin/bsdconfig/usermgmt/useredit b/usr.sbin/bsdconfig/usermgmt/useredit index 00e6ae5..60e1476 100755 --- a/usr.sbin/bsdconfig/usermgmt/useredit +++ b/usr.sbin/bsdconfig/usermgmt/useredit @@ -67,11 +67,13 @@ f_mustberoot_init # # Loop until the user Exits, Cancels or presses ESC # +defaultitem="" while :; do - f_dialog_menu_user_list + f_dialog_menu_user_list "$defaultitem" retval=$? mtag=$( f_dialog_menutag ) f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" + defaultitem="$mtag" [ $retval -eq 0 ] || f_die diff --git a/usr.sbin/bsdconfig/usermgmt/userinput b/usr.sbin/bsdconfig/usermgmt/userinput index ad62a09..ed7e841 100755 --- a/usr.sbin/bsdconfig/usermgmt/userinput +++ b/usr.sbin/bsdconfig/usermgmt/userinput @@ -1,7 +1,7 @@ #!/bin/sh #- # Copyright (c) 2012 Ron McDowell -# Copyright (c) 2012 Devin Teske +# Copyright (c) 2012-2013 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -392,17 +392,19 @@ while :; do $menu_items ) dialog_menu=$( eval $DIALOG \ - --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --menu \"\$menu_text\" $size \ - $menu_items \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\$menu_text\" $size \ + $menu_items \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) retval=$? + setvar DEFAULTITEM_$$ "$dialog_menu" setvar DIALOG_MENU_$$ "$dialog_menu" mtag=$( f_dialog_menutag ) f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" @@ -421,7 +423,7 @@ while :; do case "$mode" in Add) f_dialog_input_name "$pw_name" ;; Edit/View|Delete) - f_dialog_menu_user_list + f_dialog_menu_user_list "$pw_name" retval=$? mtag=$( f_dialog_menutag ) f_dprintf "retval=%u mtag=[%s]" $retval "$mtag" diff --git a/usr.sbin/bsdconfig/usermgmt/usermgmt b/usr.sbin/bsdconfig/usermgmt/usermgmt index d7849ae..3c5a5ef 100755 --- a/usr.sbin/bsdconfig/usermgmt/usermgmt +++ b/usr.sbin/bsdconfig/usermgmt/usermgmt @@ -82,19 +82,24 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ - --backtitle \"\$DIALOG_BACKTITLE\" \ - --hline \"\$hline\" \ - --ok-label \"\$msg_ok\" \ - --cancel-label \"\$msg_cancel\" \ - --help-button \ - --help-label \"\$msg_help\" \ - ${USE_XDIALOG:+--help \"\"} \ - --menu \"\" $size $menu_list \ + --title \"\$DIALOG_TITLE\" \ + --backtitle \"\$DIALOG_BACKTITLE\" \ + --hline \"\$hline\" \ + --ok-label \"\$msg_ok\" \ + --cancel-label \"\$msg_cancel\" \ + --help-button \ + --help-label \"\$msg_help\" \ + ${USE_XDIALOG:+--help \"\"} \ + --default-item \"\$DEFAULTITEM_$$\" \ + --menu \"\" $size $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" + + # Only update default-item on success + [ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu" + return $retval } |