Date: Mon, 22 Apr 2013 05:52:07 +0000 (UTC) From: Devin Teske <dteske@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249751 - in head/usr.sbin/bsdconfig: . console mouse networking networking/share password/include password/share security share share/media startup startup/share timezone usermgmt user... Message-ID: <201304220552.r3M5q7p4015051@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dteske Date: Mon Apr 22 05:52:06 2013 New Revision: 249751 URL: http://svnweb.freebsd.org/changeset/base/249751 Log: 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. Modified: head/usr.sbin/bsdconfig/bsdconfig head/usr.sbin/bsdconfig/console/console head/usr.sbin/bsdconfig/console/font head/usr.sbin/bsdconfig/console/keymap head/usr.sbin/bsdconfig/console/repeat head/usr.sbin/bsdconfig/console/saver head/usr.sbin/bsdconfig/console/screenmap head/usr.sbin/bsdconfig/console/ttys head/usr.sbin/bsdconfig/mouse/mouse head/usr.sbin/bsdconfig/mouse/port head/usr.sbin/bsdconfig/mouse/type head/usr.sbin/bsdconfig/networking/devices head/usr.sbin/bsdconfig/networking/hostname head/usr.sbin/bsdconfig/networking/networking head/usr.sbin/bsdconfig/networking/share/device.subr head/usr.sbin/bsdconfig/networking/share/media.subr head/usr.sbin/bsdconfig/networking/share/resolv.subr head/usr.sbin/bsdconfig/password/include/messages.subr head/usr.sbin/bsdconfig/password/share/password.subr head/usr.sbin/bsdconfig/security/kern_securelevel head/usr.sbin/bsdconfig/security/security head/usr.sbin/bsdconfig/share/media/options.subr head/usr.sbin/bsdconfig/share/strings.subr head/usr.sbin/bsdconfig/startup/misc head/usr.sbin/bsdconfig/startup/rcadd head/usr.sbin/bsdconfig/startup/rcconf head/usr.sbin/bsdconfig/startup/rcdelete head/usr.sbin/bsdconfig/startup/rcvar head/usr.sbin/bsdconfig/startup/share/rcconf.subr head/usr.sbin/bsdconfig/startup/share/rcvar.subr head/usr.sbin/bsdconfig/startup/startup head/usr.sbin/bsdconfig/timezone/timezone head/usr.sbin/bsdconfig/usermgmt/groupdel head/usr.sbin/bsdconfig/usermgmt/groupedit head/usr.sbin/bsdconfig/usermgmt/groupinput head/usr.sbin/bsdconfig/usermgmt/include/messages.subr head/usr.sbin/bsdconfig/usermgmt/share/group_input.subr head/usr.sbin/bsdconfig/usermgmt/share/user_input.subr head/usr.sbin/bsdconfig/usermgmt/userdel head/usr.sbin/bsdconfig/usermgmt/useredit head/usr.sbin/bsdconfig/usermgmt/userinput head/usr.sbin/bsdconfig/usermgmt/usermgmt Modified: head/usr.sbin/bsdconfig/bsdconfig ============================================================================== --- head/usr.sbin/bsdconfig/bsdconfig Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/bsdconfig Mon Apr 22 05:52:06 2013 (r249751) @@ -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 } Modified: head/usr.sbin/bsdconfig/console/console ============================================================================== --- head/usr.sbin/bsdconfig/console/console Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/console/console Mon Apr 22 05:52:06 2013 (r249751) @@ -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 } Modified: head/usr.sbin/bsdconfig/console/font ============================================================================== --- head/usr.sbin/bsdconfig/console/font Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/console/font Mon Apr 22 05:52:06 2013 (r249751) @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_ # 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 Modified: head/usr.sbin/bsdconfig/console/keymap ============================================================================== --- head/usr.sbin/bsdconfig/console/keymap Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/console/keymap Mon Apr 22 05:52:06 2013 (r249751) @@ -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 Modified: head/usr.sbin/bsdconfig/console/repeat ============================================================================== --- head/usr.sbin/bsdconfig/console/repeat Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/console/repeat Mon Apr 22 05:52:06 2013 (r249751) @@ -49,15 +49,15 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_ # 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 Modified: head/usr.sbin/bsdconfig/console/saver ============================================================================== --- head/usr.sbin/bsdconfig/console/saver Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/console/saver Mon Apr 22 05:52:06 2013 (r249751) @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_ # 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 Modified: head/usr.sbin/bsdconfig/console/screenmap ============================================================================== --- head/usr.sbin/bsdconfig/console/screenmap Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/console/screenmap Mon Apr 22 05:52:06 2013 (r249751) @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_ # 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 Modified: head/usr.sbin/bsdconfig/console/ttys ============================================================================== --- head/usr.sbin/bsdconfig/console/ttys Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/console/ttys Mon Apr 22 05:52:06 2013 (r249751) @@ -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\" \ Modified: head/usr.sbin/bsdconfig/mouse/mouse ============================================================================== --- head/usr.sbin/bsdconfig/mouse/mouse Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/mouse/mouse Mon Apr 22 05:52:06 2013 (r249751) @@ -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 } Modified: head/usr.sbin/bsdconfig/mouse/port ============================================================================== --- head/usr.sbin/bsdconfig/mouse/port Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/mouse/port Mon Apr 22 05:52:06 2013 (r249751) @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_ # 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 Modified: head/usr.sbin/bsdconfig/mouse/type ============================================================================== --- head/usr.sbin/bsdconfig/mouse/type Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/mouse/type Mon Apr 22 05:52:06 2013 (r249751) @@ -49,7 +49,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_ # 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 Modified: head/usr.sbin/bsdconfig/networking/devices ============================================================================== --- head/usr.sbin/bsdconfig/networking/devices Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/networking/devices Mon Apr 22 05:52:06 2013 (r249751) @@ -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 Modified: head/usr.sbin/bsdconfig/networking/hostname ============================================================================== --- head/usr.sbin/bsdconfig/networking/hostname Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/networking/hostname Mon Apr 22 05:52:06 2013 (r249751) @@ -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" Modified: head/usr.sbin/bsdconfig/networking/networking ============================================================================== --- head/usr.sbin/bsdconfig/networking/networking Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/networking/networking Mon Apr 22 05:52:06 2013 (r249751) @@ -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 } Modified: head/usr.sbin/bsdconfig/networking/share/device.subr ============================================================================== --- head/usr.sbin/bsdconfig/networking/share/device.subr Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/networking/share/device.subr Mon Apr 22 05:52:06 2013 (r249751) @@ -55,12 +55,15 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/inc ############################################################ 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 # Modified: head/usr.sbin/bsdconfig/networking/share/media.subr ============================================================================== --- head/usr.sbin/bsdconfig/networking/share/media.subr Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/networking/share/media.subr Mon Apr 22 05:52:06 2013 (r249751) @@ -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\" \ Modified: head/usr.sbin/bsdconfig/networking/share/resolv.subr ============================================================================== --- head/usr.sbin/bsdconfig/networking/share/resolv.subr Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/networking/share/resolv.subr Mon Apr 22 05:52:06 2013 (r249751) @@ -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;; Modified: head/usr.sbin/bsdconfig/password/include/messages.subr ============================================================================== --- head/usr.sbin/bsdconfig/password/include/messages.subr Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/password/include/messages.subr Mon Apr 22 05:52:06 2013 (r249751) @@ -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." Modified: head/usr.sbin/bsdconfig/password/share/password.subr ============================================================================== --- head/usr.sbin/bsdconfig/password/share/password.subr Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/password/share/password.subr Mon Apr 22 05:52:06 2013 (r249751) @@ -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" \ Modified: head/usr.sbin/bsdconfig/security/kern_securelevel ============================================================================== --- head/usr.sbin/bsdconfig/security/kern_securelevel Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/security/kern_securelevel Mon Apr 22 05:52:06 2013 (r249751) @@ -51,12 +51,11 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_ # 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 Modified: head/usr.sbin/bsdconfig/security/security ============================================================================== --- head/usr.sbin/bsdconfig/security/security Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/security/security Mon Apr 22 05:52:06 2013 (r249751) @@ -49,36 +49,53 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_ # 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 } Modified: head/usr.sbin/bsdconfig/share/media/options.subr ============================================================================== --- head/usr.sbin/bsdconfig/share/media/options.subr Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/share/media/options.subr Mon Apr 22 05:52:06 2013 (r249751) @@ -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 ) Modified: head/usr.sbin/bsdconfig/share/strings.subr ============================================================================== --- head/usr.sbin/bsdconfig/share/strings.subr Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/share/strings.subr Mon Apr 22 05:52:06 2013 (r249751) @@ -25,6 +25,21 @@ if [ ! "$_STRINGS_SUBR" ]; then _STRINGS # 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 Modified: head/usr.sbin/bsdconfig/startup/misc ============================================================================== --- head/usr.sbin/bsdconfig/startup/misc Mon Apr 22 05:48:18 2013 (r249750) +++ head/usr.sbin/bsdconfig/startup/misc Mon Apr 22 05:52:06 2013 (r249751) @@ -56,10 +56,14 @@ UNAME_P=$( uname -p ) # Processor Archit # 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" ) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304220552.r3M5q7p4015051>