1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-29 12:03:03 +00:00

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
This commit is contained in:
Devin Teske 2013-06-19 00:13:54 +00:00
parent b17d3670ee
commit 9cd8fcc642
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=251980

View File

@ -378,136 +378,35 @@ 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
[ "$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
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
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
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
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=$( 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
fi
fi # copymode
return $FAILURE
fi
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
msg=$( printf "$msg_removed_file" "$_PATH_LOCALTIME" )
if [ "$USEDIALOG" ]; then
f_dialog_title "$msg_done"
f_dialog_msgbox "$msg"
@ -517,7 +416,104 @@ f_install_zoneinfo_file()
fi
fi
fi # REALLYDOIT
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=$( 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
fi
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
}