Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jun 2013 00:13:54 +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: r251980 - head/usr.sbin/bsdconfig/timezone/share
Message-ID:  <201306190013.r5J0Ds6U075722@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306190013.r5J0Ds6U075722>