From owner-svn-src-all@FreeBSD.ORG Tue Jun 18 23:18:32 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 97076123; Tue, 18 Jun 2013 23:18:32 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 78E4E1A1D; Tue, 18 Jun 2013 23:18:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5INIW4T056730; Tue, 18 Jun 2013 23:18:32 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5INIWP5056729; Tue, 18 Jun 2013 23:18:32 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201306182318.r5INIWP5056729@svn.freebsd.org> From: Devin Teske Date: Tue, 18 Jun 2013 23:18:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251975 - head/usr.sbin/bsdconfig/startup X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jun 2013 23:18:32 -0000 Author: dteske Date: Tue Jun 18 23:18:32 2013 New Revision: 251975 URL: http://svnweb.freebsd.org/changeset/base/251975 Log: Perform some code consolidation and replace nested case-statements with more logical if-else statements for each menu selection. Modified: head/usr.sbin/bsdconfig/startup/misc Modified: head/usr.sbin/bsdconfig/startup/misc ============================================================================== --- head/usr.sbin/bsdconfig/startup/misc Tue Jun 18 23:14:45 2013 (r251974) +++ head/usr.sbin/bsdconfig/startup/misc Tue Jun 18 23:18:32 2013 (r251975) @@ -346,86 +346,90 @@ while :; do case "$mtag" in "X $msg_exit") break ;; + ?" [X] "*) toggled=1 ;; + *) toggled= ;; + esac + + case "$mtag" in + # Simple On/Off toggle bits ?" ["?"] $msg_apm") - case "$mtag" in - ?" [X] "*) err=$( f_sysrc_set apm_enable NO 2>&1 ) ;; - ?" [ ] "*) err=$( f_sysrc_set apm_enable YES 2>&1 ) ;; - esac - [ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;; - ?" ["?"] $msg_startup_dirs") - dialog_input_value \ - "$msg_startup_dirs_desc" \ - "$( f_sysrc_get local_startup )" - if [ $? -eq $SUCCESS ]; then - err=$( f_sysrc_set local_startup "$value" ) || - f_dialog_msgbox "$err\n" + if [ "$toggled" ]; then + err=$( f_sysrc_set apm_enable NO 2>&1 ) + else + err=$( f_sysrc_set apm_enable YES 2>&1 ) fi ;; ?" ["?"] $msg_named") - case "$mtag" in - ?" [X] "*) err=$( f_sysrc_set named_enable NO 2>&1 ) ;; - ?" [ ] "*) err=$( f_sysrc_set named_enable YES 2>&1 ) ;; - esac - [ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;; - ?" ["?"] $msg_named_flags") - dialog_input_value \ - "$msg_named_flags_desc" \ - "$( f_sysrc_get named_flags )" - if [ $? -eq $SUCCESS ]; then - err=$( f_sysrc_set named_flags "$value" ) || - f_dialog_msgbox "$err\n" + if [ "$toggled" ]; then + err=$( f_sysrc_set named_enable NO 2>&1 ) + else + err=$( f_sysrc_set named_enable YES 2>&1 ) + fi + ;; + ?" ["?"] $msg_accounting") + if [ "$toggled" ]; then + err=$( f_sysrc_set accounting_enable NO 2>&1 ) + else + err=$( f_sysrc_set accounting_enable YES 2>&1 ) fi ;; + ?" ["?"] $msg_lpd") + if [ "$toggled" ]; then + err=$( f_sysrc_set lpd_enable NO 2>&1 ) + else + err=$( f_sysrc_set lpd_enable YES 2>&1 ) + fi + ;; + ?" ["?"] $msg_sco") + if [ "$toggled" ]; then + err=$( f_sysrc_set ibcs2_enable NO 2>&1 ) + else + err=$( f_sysrc_set ibcs2_enable YES 2>&1 ) + fi + ;; + ?" ["?"] $msg_svr4") + if [ "$toggled" ]; then + err=$( f_sysrc_set svr4_enable NO 2>&1 ) + else + err=$( f_sysrc_set svr4_enable YES 2>&1 ) + fi + ;; + # Multi-variable On/Off toggle bits ?" ["?"] $msg_nis_client") - case "$mtag" in - ?" [X] "*) err=$( f_sysrc_set nis_client_enable NO 2>&1 ) ;; - ?" [ ] "*) + if [ "$toggled" ]; then + err=$( f_sysrc_set nis_client_enable NO 2>&1 ) + else err=$( f_sysrc_set nis_client_enable YES 2>&1 ) \ - && err=$( f_sysrc_set rpcbind_enable YES 2>&1 ) ;; - esac - [ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;; - ?" ["?"] $msg_nis_domainname") - dialog_input_value \ - "$msg_nis_domainname_desc" \ - "$( f_sysrc_get nisdomainname )" - if [ $? -eq $SUCCESS ]; then - err=$( f_sysrc_set nisdomainname "$value" ) || - f_dialog_msgbox "$err\n" + && err=$( f_sysrc_set rpcbind_enable YES 2>&1 ) fi ;; ?" ["?"] $msg_nis_server") - case "$mtag" in - ?" [X] "*) err=$( f_sysrc_set nis_server_enable NO 2>&1 ) ;; - ?" [ ] "*) + if [ "$toggled" ]; then + err=$( f_sysrc_set nis_server_enable NO 2>&1 ) + else err=$( f_sysrc_set nis_server_enable YES 2>&1 ) \ - && err=$( f_sysrc_set rpcbind_enable YES 2>&1 ) ;; - esac - [ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;; - ?" ["?"] $msg_accounting") - case "$mtag" in - ?" [X] "*) err=$( f_sysrc_set accounting_enable NO 2>&1 ) ;; - ?" [ ] "*) err=$( f_sysrc_set accounting_enable YES 2>&1 ) ;; - esac - [ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;; - ?" ["?"] $msg_lpd") - case "$mtag" in - ?" [X] "*) err=$( f_sysrc_set lpd_enable NO 2>&1 ) ;; - ?" [ ] "*) err=$( f_sysrc_set lpd_enable YES 2>&1 ) ;; - esac - [ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;; - ?" ["?"] $msg_sco") - case "$mtag" in - ?" [X] "*) err=$( f_sysrc_set ibcs2_enable NO 2>&1 ) ;; - ?" [ ] "*) err=$( f_sysrc_set ibcs2_enable YES 2>&1 ) ;; - esac - [ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;; - ?" ["?"] $msg_svr4") - case "$mtag" in - ?" [X] "*) err=$( f_sysrc_set svr4_enable NO 2>&1 ) ;; - ?" [ ] "*) err=$( f_sysrc_set svr4_enable YES 2>&1 ) ;; - esac - [ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;; + && err=$( f_sysrc_set rpcbind_enable YES 2>&1 ) + fi + ;; + # Checkboxes for non-boolean options + ?" ["?"] $msg_nis_domainname") + dialog_input_value "$msg_nis_domainname_desc" \ + "$( f_sysrc_get nisdomainname )" || continue + err=$( f_sysrc_set nisdomainname "$value" 2>&1 ) + ;; + ?" ["?"] $msg_startup_dirs") + dialog_input_value "$msg_startup_dirs_desc" \ + "$( f_sysrc_get local_startup )" || continue + err=$( f_sysrc_set local_startup "$value" 2>&1 ) + ;; + ?" ["?"] $msg_named_flags") + dialog_input_value "$msg_named_flags_desc" \ + "$( f_sysrc_get named_flags )" || continue + err=$( f_sysrc_set named_flags "$value" 2>&1 ) + ;; esac + + [ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" done exit $SUCCESS