From owner-svn-src-head@FreeBSD.ORG Wed Jun 19 00:13:55 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 03B354C1; Wed, 19 Jun 2013 00:13:55 +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 EA13C1C2E; Wed, 19 Jun 2013 00:13:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5J0Dsk8075723; Wed, 19 Jun 2013 00:13:54 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5J0Ds6U075722; Wed, 19 Jun 2013 00:13:54 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201306190013.r5J0Ds6U075722@svn.freebsd.org> From: Devin Teske Date: Wed, 19 Jun 2013 00:13:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251980 - head/usr.sbin/bsdconfig/timezone/share X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jun 2013 00:13:55 -0000 Author: dteske Date: Wed Jun 19 00:13:54 2013 New Revision: 251980 URL: http://svnweb.freebsd.org/changeset/base/251980 Log: Change a humongous if-statement at the end of f_install_zoneinfo_file() into an early return, allowing a huge chunk of code to be indented one-level less Modified: head/usr.sbin/bsdconfig/timezone/share/zones.subr Modified: head/usr.sbin/bsdconfig/timezone/share/zones.subr ============================================================================== --- head/usr.sbin/bsdconfig/timezone/share/zones.subr Wed Jun 19 00:09:21 2013 (r251979) +++ head/usr.sbin/bsdconfig/timezone/share/zones.subr Wed Jun 19 00:13:54 2013 (r251980) @@ -378,146 +378,142 @@ f_install_zoneinfo_file() fi fi - if [ "$REALLYDOIT" ]; then - if [ ! "$zoneinfo_file" ]; then - err=$( rm -f "$_PATH_LOCALTIME" 2>&1 ) - if [ "$err" ]; then - if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_error" - f_dialog_msgbox "$err" - f_dialog_title_restore - else - f_err "%s\n" "$err" - fi - return $FAILURE - fi - - err=$( rm -f "$_PATH_DB" 2>&1 ) - if [ "$err" ]; then - if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_error" - f_dialog_msgbox "$err" - f_dialog_title_restore - else - f_err "%s\n" "$err" - fi - return $FAILURE - fi - - if [ "$VERBOSE" ]; then - msg=$( printf "$msg_removed_file" \ - "$_PATH_LOCALTIME" ) - if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_done" - f_dialog_msgbox "$msg" - f_dialog_title_restore - else - printf "%s\n" "$msg" - fi + [ "$REALLYDOIT" ] || return $SUCCESS + + if [ ! "$zoneinfo_file" ]; then + err=$( rm -f "$_PATH_LOCALTIME" 2>&1 ) + if [ "$err" ]; then + if [ "$USEDIALOG" ]; then + f_dialog_title "$msg_error" + f_dialog_msgbox "$err" + f_dialog_title_restore + else + f_err "%s\n" "$err" fi + return $FAILURE + fi - return $SUCCESS + err=$( rm -f "$_PATH_DB" 2>&1 ) + if [ "$err" ]; then + if [ "$USEDIALOG" ]; then + f_dialog_title "$msg_error" + f_dialog_msgbox "$err" + f_dialog_title_restore + else + f_err "%s\n" "$err" + fi + return $FAILURE + fi - fi # ! zoneinfo_file + if [ "$VERBOSE" ]; then + msg=$( printf "$msg_removed_file" "$_PATH_LOCALTIME" ) + if [ "$USEDIALOG" ]; then + f_dialog_title "$msg_done" + f_dialog_msgbox "$msg" + f_dialog_title_restore + else + printf "%s\n" "$msg" + fi + fi - if [ "$copymode" ]; then + return $SUCCESS + + fi # ! zoneinfo_file + + if [ "$copymode" ]; then + + err=$( rm -f "$_PATH_LOCALTIME" 2>&1 ) + if [ "$err" ]; then + if [ "$USEDIALOG" ]; then + f_dialog_title "$msg_error" + f_dialog_msgbox "$err" + f_dialog_title_restore + else + f_err "%s\n" "$err" + fi + return $FAILURE + fi + + err=$( umask 222 && : 2>&1 > "$_PATH_LOCALTIME" ) + if [ "$err" ]; then + if [ "$USEDIALOG" ]; then + f_dialog_title "$msg_error" + f_dialog_msgbox "$err" + f_dialog_title_restore + else + f_err "%s\n" "$err" + fi + return $FAILURE + fi - err=$( rm -f "$_PATH_LOCALTIME" 2>&1 ) - if [ "$err" ]; then - if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_error" - f_dialog_msgbox "$err" - f_dialog_title_restore - else - f_err "%s\n" "$err" - fi - return $FAILURE - fi - - err=$( umask 222 && : 2>&1 > "$_PATH_LOCALTIME" ) - if [ "$err" ]; then - if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_error" - f_dialog_msgbox "$err" - f_dialog_title_restore - else - f_err "%s\n" "$err" - fi - return $FAILURE - fi - - err=$( cat "$zoneinfo_file" 2>&1 > "$_PATH_LOCALTIME" ) - if [ "$err" ]; then - if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_error" - f_dialog_msgbox "$err" - f_dialog_title_restore - else - f_err "%s\n" "$err" - fi - return $FAILURE - fi - - else # ! copymode - - err=$( ( :< "$zoneinfo_file" ) 2>&1 ) - if [ "$err" ]; then - if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_error" - f_dialog_msgbox "$err" - f_dialog_title_restore - else - f_err "%s\n" "$err" - fi - return $FAILURE - fi - - err=$( rm -f "$_PATH_LOCALTIME" 2>&1 ) - if [ "$err" ]; then - if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_error" - f_dialog_msgbox "$err" - f_dialog_title_restore - else - f_err "%s\n" "$err" - fi - return $FAILURE - fi - - err=$( ln -s "$zoneinfo_file" "$_PATH_LOCALTIME" 2>&1 ) - if [ "$err" ]; then - if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_error" - f_dialog_msgbox "$err" - f_dialog_title_restore - else - f_err "%s\n" "$err" - fi - return $FAILURE + err=$( cat "$zoneinfo_file" 2>&1 > "$_PATH_LOCALTIME" ) + if [ "$err" ]; then + if [ "$USEDIALOG" ]; then + f_dialog_title "$msg_error" + f_dialog_msgbox "$err" + f_dialog_title_restore + else + f_err "%s\n" "$err" fi + return $FAILURE + fi - fi # copymode + else # ! copymode - if [ "$VERBOSE" ]; then - if [ "$copymode" ]; then - msg=$( printf "$msg_copied_timezone_file" \ - "$zoneinfo_file" \ - "$_PATH_LOCALTIME" ) - else - msg=$( printf "$msg_created_symlink" \ - "$_PATH_LOCALTIME" \ - "$zoneinfo_file" ) + err=$( ( :< "$zoneinfo_file" ) 2>&1 ) + if [ "$err" ]; then + if [ "$USEDIALOG" ]; then + f_dialog_title "$msg_error" + f_dialog_msgbox "$err" + f_dialog_title_restore + else + f_err "%s\n" "$err" fi + return $FAILURE + fi + + err=$( rm -f "$_PATH_LOCALTIME" 2>&1 ) + if [ "$err" ]; then if [ "$USEDIALOG" ]; then - f_dialog_title "$msg_done" - f_dialog_msgbox "$msg" + f_dialog_title "$msg_error" + f_dialog_msgbox "$err" f_dialog_title_restore else - printf "%s\n" "$msg" + f_err "%s\n" "$err" + fi + return $FAILURE + fi + + err=$( ln -s "$zoneinfo_file" "$_PATH_LOCALTIME" 2>&1 ) + if [ "$err" ]; then + if [ "$USEDIALOG" ]; then + f_dialog_title "$msg_error" + f_dialog_msgbox "$err" + f_dialog_title_restore + else + f_err "%s\n" "$err" fi + return $FAILURE fi - fi # REALLYDOIT + fi # copymode + + if [ "$VERBOSE" ]; then + if [ "$copymode" ]; then + msg=$( printf "$msg_copied_timezone_file" \ + "$zoneinfo_file" "$_PATH_LOCALTIME" ) + else + msg=$( printf "$msg_created_symlink" \ + "$_PATH_LOCALTIME" "$zoneinfo_file" ) + fi + if [ "$USEDIALOG" ]; then + f_dialog_title "$msg_done" + f_dialog_msgbox "$msg" + f_dialog_title_restore + else + printf "%s\n" "$msg" + fi + fi return $SUCCESS }