[arch-projects] [initscripts] [PATCH 11/18] Get rid of simple if-constucts by using '&&' and '||'
Kurt J. Bosch
kjb-temp-2009 at alpenjodel.de
Mon Jun 27 13:11:17 EDT 2011
---
functions | 27 +++++++--------------------
rc.sysinit | 18 ++++--------------
2 files changed, 11 insertions(+), 34 deletions(-)
diff --git a/functions b/functions
index e30fcf0..d3da4e1 100644
--- a/functions
+++ b/functions
@@ -237,11 +237,7 @@ status_stopped() {
}
ck_status() {
- if ! ck_daemon "$1"; then
- status_started
- else
- status_stopped
- fi
+ ! ck_daemon "$1" && status_started || status_stopped
}
# Return PID of $1
@@ -320,9 +316,8 @@ udevd_modprobe() {
stat_done
# Load modules from the MODULES array defined in rc.conf
- if [[ -f /proc/modules ]] && (( ${#MODULES[*]} )); then
+ [[ -f /proc/modules ]] && (( ${#MODULES[*]} )) &&
status "Loading Modules" modprobe -ab "${MODULES[@]}"
- fi
status "Waiting for UDev uevents to be processed" \
udevadm settle --timeout=${UDEV_TIMEOUT:-30}
@@ -338,11 +333,8 @@ activate_vgs() {
stat_busy "Activating LVM2 groups"
# Kernel 2.6.x, LVM2 groups
/sbin/modprobe -q dm-mod 2>/dev/null
- if /sbin/vgchange --sysinit -a y >/dev/null; then
- stat_done
- else
- stat_fail
- fi
+ /sbin/vgchange --sysinit -a y >/dev/null
+ (( $? == 0 )) && stat_done || stat_fail
}
# Arch cryptsetup packages traditionally contained the binaries
@@ -386,11 +378,7 @@ fsck_all() {
fsck -A -T -C$FSCK_FD -a -t "$NETFS,noopts=_netdev" $FORCEFSCK >$FSCK_OUT 2>$FSCK_ERR
local fsckret=$?
run_hook sysinit_postfsck
- if (( fsckret > 1 )); then
- stat_fail
- else
- stat_done
- fi
+ (( fsckret <= 1 )) && stat_done || stat_fail
return $fsckret
}
@@ -398,9 +386,8 @@ fsck_all() {
fsck_reboot() {
# $1 = exit code returned by fsck
# Ignore conditions 'FS errors corrected' and 'Cancelled by the user'
- if (( ($1 | 33) == 33 )); then
- return 0
- elif (( $1 & 2 )); then
+ (( ($1 | 33) == 33 )) && return 0
+ if (( $1 & 2 )); then
echo
echo "********************** REBOOT REQUIRED *********************"
echo "* *"
diff --git a/rc.sysinit b/rc.sysinit
index d51e88b..ee16c23 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -68,11 +68,7 @@ if [[ $HWCLOCK_PARAMS ]]; then
# is used. If HARDWARECLOCK is not set in rc.conf, the value in
# /var/lib/hwclock/adjfile is used (in this case /var can not be a separate
# partition).
- if TZ=$TIMEZONE hwclock $HWCLOCK_PARAMS; then
- stat_done
- else
- stat_fail
- fi
+ TZ=$TIMEZONE hwclock $HWCLOCK_PARAMS && stat_done || stat_fail
fi
# Start/trigger UDev, load MODULES and settle UDev
@@ -175,15 +171,9 @@ if [[ -f /etc/crypttab && $CS ]] && grep -q ^[^#] /etc/crypttab; then
return $failed
}
crypto_unlocked=0
- if read_crypttab do_unlock; then
- stat_done
- else
- stat_fail
- fi
- if (( crypto_unlocked == 1 )); then
- # Maybe someone has LVM on an encrypted block device
- activate_vgs
- fi
+ read_crypttab do_unlock && stat_done || stat_fail
+ # Maybe someone has LVM on an encrypted block device
+ (( crypto_unlocked == 1 )) && activate_vgs
fi
# Check filesystems
--
1.7.1
More information about the arch-projects
mailing list