From 9170aa51fd4e8336cc34db3a1aa29989a024b50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 23 Oct 2017 23:20:31 +0300 Subject: Avoid some unnecessary stat calls --- rc.d/init.d/functions | 4 ++-- service | 2 +- systemd/fedora-domainname | 2 +- systemd/fedora-import-state | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rc.d/init.d/functions b/rc.d/init.d/functions index 63686737..2e3da964 100644 --- a/rc.d/init.d/functions +++ b/rc.d/init.d/functions @@ -59,7 +59,7 @@ systemctl_redirect () { [ -z "${COLUMNS:-}" ] && COLUMNS=80 if [ -z "${CONSOLETYPE:-}" ]; then - if [ -c "/dev/stderr" -a -r "/dev/stderr" ]; then + if [ -c "/dev/stderr" ] && [ -r "/dev/stderr" ]; then CONSOLETYPE="$(/sbin/consoletype < /dev/stderr 2>/dev/null)" else CONSOLETYPE="serial" @@ -194,7 +194,7 @@ __pids_var_run() { local pid_dir=$(/usr/bin/dirname $pid_file > /dev/null) local binary=$3 - [ -d "$pid_dir" -a ! -r "$pid_dir" ] && return 4 + [ -d "$pid_dir" ] && [ ! -r "$pid_dir" ] && return 4 pid= if [ -f "$pid_file" ] ; then diff --git a/service b/service index 9b25e85d..f3c524ae 100755 --- a/service +++ b/service @@ -79,7 +79,7 @@ if [ -f "${SERVICEDIR}/${SERVICE}" ]; then /bin/systemctl stop ${SERVICE}.service fi env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS} -elif [ -x "${ACTIONDIR}/${SERVICE}/${ACTION}" -a -n "${ACTION}" ]; then +elif [ -n "${ACTION}" ] && [ -x "${ACTIONDIR}/${SERVICE}/${ACTION}" ]; then env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS} elif `echo $ACTION | egrep -qw "start|stop|restart|try-restart|reload|force-reload|status|condrestart"` ; then SERVICE_MANGLED=$(/usr/bin/systemd-escape --mangle ${SERVICE}) diff --git a/systemd/fedora-domainname b/systemd/fedora-domainname index 17f8ea8c..5c934584 100755 --- a/systemd/fedora-domainname +++ b/systemd/fedora-domainname @@ -1,7 +1,7 @@ #!/usr/bin/bash . /etc/sysconfig/network -if [ -n "${NISDOMAIN}" -a -x /usr/bin/domainname ]; then +if [ -n "${NISDOMAIN}" ] && [ -x /usr/bin/domainname ]; then domainname ${NISDOMAIN} exit $? fi diff --git a/systemd/fedora-import-state b/systemd/fedora-import-state index 16447026..85bc4817 100755 --- a/systemd/fedora-import-state +++ b/systemd/fedora-import-state @@ -34,6 +34,6 @@ IFS=$IFS_backup # Run restorecon on the copied files: # =================================== -if [ -e /sys/fs/selinux/enforce -a -x /usr/sbin/restorecon ]; then +if [ -e /sys/fs/selinux/enforce ] && [ -x /usr/sbin/restorecon ]; then find . -mindepth 1 -print0 | { cd / && xargs --null restorecon -iF; } fi -- cgit v1.2.1