summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-06-19 00:13:54 +0000
committerdteske <dteske@FreeBSD.org>2013-06-19 00:13:54 +0000
commit2ebb6eda7760e5e54d16cfe01339a77b21677d07 (patch)
treea516116322c69bd4f54c7d592f3d924dfa4e4601 /usr.sbin/bsdconfig
parented69dff3805912007dfa783df027f93c952a12b3 (diff)
downloadFreeBSD-src-2ebb6eda7760e5e54d16cfe01339a77b21677d07.zip
FreeBSD-src-2ebb6eda7760e5e54d16cfe01339a77b21677d07.tar.gz
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
Diffstat (limited to 'usr.sbin/bsdconfig')
-rw-r--r--usr.sbin/bsdconfig/timezone/share/zones.subr224
1 files changed, 110 insertions, 114 deletions
diff --git a/usr.sbin/bsdconfig/timezone/share/zones.subr b/usr.sbin/bsdconfig/timezone/share/zones.subr
index a7ef373..cbadc5b 100644
--- a/usr.sbin/bsdconfig/timezone/share/zones.subr
+++ b/usr.sbin/bsdconfig/timezone/share/zones.subr
@@ -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
+ [ "$REALLYDOIT" ] || 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
+ 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
- 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
+ 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
- return $SUCCESS
+ 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
- fi # ! zoneinfo_file
+ return $SUCCESS
- if [ "$copymode" ]; then
+ fi # ! zoneinfo_file
- 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
+ if [ "$copymode" ]; then
- 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
+ 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=$( 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
+ 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
- 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
+ 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
- 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
+ else # ! copymode
- 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=$( ( :< "$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
- fi # copymode
-
- if [ "$VERBOSE" ]; then
- if [ "$copymode" ]; then
- msg=$( printf "$msg_copied_timezone_file" \
- "$zoneinfo_file" \
- "$_PATH_LOCALTIME" )
+ 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
- msg=$( printf "$msg_created_symlink" \
- "$_PATH_LOCALTIME" \
- "$zoneinfo_file" )
+ 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_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
- 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
}
OpenPOWER on IntegriCloud