From 99342bd41559eafe440ef8498772fd92f314f0c5 Mon Sep 17 00:00:00 2001 From: rpe Date: Thu, 11 Jan 2018 21:09:26 +0000 Subject: [PATCH] - change [] tests to [[]] - change -a, -o to &&, || inside [[]] - remove unecessary quoting inside [[]] - remove X"" constructs inside [[]] - remove \ (line continuation) in case of &&, || and pipes - replace backticks with $() discussed with and OK aja@ OK tb --- etc/rc.d/amd | 4 ++-- etc/rc.d/bootparamd | 4 ++-- etc/rc.d/iked | 4 ++-- etc/rc.d/isakmpd | 4 ++-- etc/rc.d/ldattach | 4 ++-- etc/rc.d/mopd | 4 ++-- etc/rc.d/mountd | 6 +++--- etc/rc.d/nfsd | 4 ++-- etc/rc.d/rarpd | 4 ++-- etc/rc.d/spamd | 4 ++-- etc/rc.d/spamlogd | 4 ++-- etc/rc.d/unbound | 4 ++-- etc/rc.d/ypbind | 4 ++-- etc/rc.d/yppasswdd | 24 ++++++++++++------------ etc/rc.d/ypserv | 4 ++-- 15 files changed, 41 insertions(+), 41 deletions(-) diff --git a/etc/rc.d/amd b/etc/rc.d/amd index 348ebcb98c0..3bfe9dc555e 100644 --- a/etc/rc.d/amd +++ b/etc/rc.d/amd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: amd,v 1.8 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: amd,v 1.9 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/sbin/amd" @@ -11,7 +11,7 @@ rc_reload=NO rc_stop=NO rc_pre() { - [ -e ${amd_master} ] || return 1 + [[ -e ${amd_master} ]] || return 1 daemon_flags="${daemon_flags} $(print -rn -- $(< ${amd_master}))" } diff --git a/etc/rc.d/bootparamd b/etc/rc.d/bootparamd index c3561f47409..651d797f766 100644 --- a/etc/rc.d/bootparamd +++ b/etc/rc.d/bootparamd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: bootparamd,v 1.3 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: bootparamd,v 1.4 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/sbin/rpc.bootparamd" @@ -9,7 +9,7 @@ daemon="/usr/sbin/rpc.bootparamd" rc_reload=NO rc_pre() { - [ -s /etc/bootparams ] + [[ -s /etc/bootparams ]] } rc_cmd $1 diff --git a/etc/rc.d/iked b/etc/rc.d/iked index 176a3bd90b6..405f0adbe4a 100644 --- a/etc/rc.d/iked +++ b/etc/rc.d/iked @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: iked,v 1.4 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: iked,v 1.5 2018/01/11 21:09:26 rpe Exp $ daemon="/sbin/iked" @@ -9,7 +9,7 @@ daemon="/sbin/iked" pexp="iked: parent.*" rc_pre() { - [ X"${sasyncd_flags}" != X"NO" ] && \ + [[ ${sasyncd_flags} != NO ]] && daemon_flags="-S ${daemon_flags}" #return 0 # child will not return a config parsing error to the parent diff --git a/etc/rc.d/isakmpd b/etc/rc.d/isakmpd index 70cf07d7721..1f554005b9c 100644 --- a/etc/rc.d/isakmpd +++ b/etc/rc.d/isakmpd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: isakmpd,v 1.2 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: isakmpd,v 1.3 2018/01/11 21:09:26 rpe Exp $ daemon="/sbin/isakmpd" @@ -9,7 +9,7 @@ daemon="/sbin/isakmpd" pexp="isakmpd: monitor \[priv\]" rc_pre() { - [ X"${sasyncd_flags}" != X"NO" ] && \ + [[ ${sasyncd_flags} != NO ]] && daemon_flags="-S ${daemon_flags}" return 0 } diff --git a/etc/rc.d/ldattach b/etc/rc.d/ldattach index 42e2c478a94..259568ea059 100644 --- a/etc/rc.d/ldattach +++ b/etc/rc.d/ldattach @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: ldattach,v 1.3 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: ldattach,v 1.4 2018/01/11 21:09:26 rpe Exp $ daemon="/sbin/ldattach" @@ -9,7 +9,7 @@ daemon="/sbin/ldattach" rc_reload=NO rc_pre() { - [ -n "${ldattach_flags}" ] + [[ -n ${ldattach_flags} ]] } rc_cmd $1 diff --git a/etc/rc.d/mopd b/etc/rc.d/mopd index 11f03c023a1..49706eccf1f 100644 --- a/etc/rc.d/mopd +++ b/etc/rc.d/mopd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: mopd,v 1.4 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: mopd,v 1.5 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/sbin/mopd" daemon_flags="-a" @@ -10,7 +10,7 @@ daemon_flags="-a" rc_reload=NO rc_pre() { - [ -d /tftpboot/mop ] + [[ -d /tftpboot/mop ]] } rc_cmd $1 diff --git a/etc/rc.d/mountd b/etc/rc.d/mountd index c18337991fc..ffedeb74fe9 100644 --- a/etc/rc.d/mountd +++ b/etc/rc.d/mountd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: mountd,v 1.7 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: mountd,v 1.8 2018/01/11 21:09:26 rpe Exp $ daemon="/sbin/mountd" @@ -10,8 +10,8 @@ pexp="mountd: \[priv\]" rc_stop=NO rc_pre() { - [ -s /etc/exports ] && grep -qv '^#' /etc/exports && \ - rm -f /var/db/mountdtab && \ + [[ -s /etc/exports ]] && grep -qv '^#' /etc/exports && + rm -f /var/db/mountdtab && echo -n > /var/db/mountdtab } diff --git a/etc/rc.d/nfsd b/etc/rc.d/nfsd index 665552b8798..2020f1593ba 100644 --- a/etc/rc.d/nfsd +++ b/etc/rc.d/nfsd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: nfsd,v 1.7 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: nfsd,v 1.8 2018/01/11 21:09:26 rpe Exp $ daemon="/sbin/nfsd" daemon_flags="-tun 4" @@ -12,7 +12,7 @@ pexp="(${daemon}( |$)|nfsd: (master|server)$)" rc_reload=NO rc_pre() { - [ -s /etc/exports ] && grep -qv '^#' /etc/exports + [[ -s /etc/exports ]] && grep -qv '^#' /etc/exports } rc_cmd $1 diff --git a/etc/rc.d/rarpd b/etc/rc.d/rarpd index 779ebb451dd..98f5ad346e3 100644 --- a/etc/rc.d/rarpd +++ b/etc/rc.d/rarpd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: rarpd,v 1.4 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: rarpd,v 1.5 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/sbin/rarpd" daemon_flags="-a" @@ -10,7 +10,7 @@ daemon_flags="-a" rc_reload=NO rc_pre() { - [ -s /etc/ethers ] + [[ -s /etc/ethers ]] } rc_cmd $1 diff --git a/etc/rc.d/spamd b/etc/rc.d/spamd index dfc06d281de..10971e347f3 100644 --- a/etc/rc.d/spamd +++ b/etc/rc.d/spamd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: spamd,v 1.9 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: spamd,v 1.10 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/libexec/spamd" @@ -10,7 +10,7 @@ pexp="spamd: \[priv\].*" rc_reload=NO rc_pre() { - if [ X"${spamd_black}" != X"NO" ]; then + if [[ ${spamd_black} != NO ]]; then daemon_flags="-b ${daemon_flags}" spamd_setup_flags="-b" fi diff --git a/etc/rc.d/spamlogd b/etc/rc.d/spamlogd index 1c24c2bf818..ced8f07edbd 100644 --- a/etc/rc.d/spamlogd +++ b/etc/rc.d/spamlogd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: spamlogd,v 1.3 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: spamlogd,v 1.4 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/libexec/spamlogd" @@ -9,7 +9,7 @@ daemon="/usr/libexec/spamlogd" rc_reload=NO rc_pre() { - [ X"${spamd_flags}" != X"NO" -a X"${spamd_black}" = X"NO" ] + [[ ${spamd_flags} != NO && ${spamd_black} == NO ]] if pfctl -si | grep -q Enabled; then ifconfig pflog0 create if ifconfig pflog0; then diff --git a/etc/rc.d/unbound b/etc/rc.d/unbound index fd1e2e7c64b..a27a67032ca 100644 --- a/etc/rc.d/unbound +++ b/etc/rc.d/unbound @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: unbound,v 1.4 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: unbound,v 1.5 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/sbin/unbound" daemon_flags="-c /var/unbound/etc/unbound.conf" @@ -17,7 +17,7 @@ rc_pre() { } rc_start() { - /usr/sbin/unbound-checkconf > /dev/null && \ + /usr/sbin/unbound-checkconf > /dev/null && ${rcexec} "unbound ${daemon_flags}" } diff --git a/etc/rc.d/ypbind b/etc/rc.d/ypbind index ddb450e6212..d28b8d79d5c 100644 --- a/etc/rc.d/ypbind +++ b/etc/rc.d/ypbind @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: ypbind,v 1.8 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: ypbind,v 1.9 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/sbin/ypbind" @@ -10,7 +10,7 @@ rc_bg=YES rc_reload=NO rc_pre() { - [ X"`domainname`" != X"" ] + [[ -n $(domainname) ]] } rc_post() { diff --git a/etc/rc.d/yppasswdd b/etc/rc.d/yppasswdd index 5fb13ac4dfd..1e12d23a321 100644 --- a/etc/rc.d/yppasswdd +++ b/etc/rc.d/yppasswdd @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: yppasswdd,v 1.5 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: yppasswdd,v 1.6 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/sbin/rpc.yppasswdd" @@ -9,20 +9,20 @@ daemon="/usr/sbin/rpc.yppasswdd" rc_reload=NO rc_pre() { - [ X"`domainname`" != X"" -a -d /var/yp/`domainname` ] || \ + [[ -n $(domainname) && -d /var/yp/$(domainname) ]] || return 1 - _host1=`ypwhich -m passwd 2> /dev/null` - _host2=`hostname` - if [ `grep '^lookup' /etc/resolv.conf | grep yp | wc -c` -ne 0 ]; then - _host1=`ypmatch $_host1 hosts | cut -d' ' -f2` - _host2=`ypmatch $_host2 hosts | cut -d' ' -f2 | head -1` + _host1=$(ypwhich -m passwd 2> /dev/null) + _host2=$(hostname) + if [[ $(grep '^lookup' /etc/resolv.conf | grep yp | wc -c) -ne 0 ]]; then + _host1=$(ypmatch $_host1 hosts | cut -d' ' -f2) + _host2=$(ypmatch $_host2 hosts | cut -d' ' -f2 | head -1) else - _host1=`echo $_host1 | nslookup | grep '^Name: ' | \ - sed -e 's/^Name: //'` - _host2=`echo $_host2 | nslookup | grep '^Name: ' | \ - sed -e 's/^Name: //'` + _host1=$(echo $_host1 | nslookup | grep '^Name: ' | + sed -e 's/^Name: //') + _host2=$(echo $_host2 | nslookup | grep '^Name: ' | + sed -e 's/^Name: //') fi - [ "$_host2" = "$_host1" ] + [[ $_host2 == $_host1 ]] } rc_cmd $1 diff --git a/etc/rc.d/ypserv b/etc/rc.d/ypserv index ccbf31fa3df..803ac50f23b 100644 --- a/etc/rc.d/ypserv +++ b/etc/rc.d/ypserv @@ -1,13 +1,13 @@ #!/bin/ksh # -# $OpenBSD: ypserv,v 1.5 2018/01/11 19:52:12 rpe Exp $ +# $OpenBSD: ypserv,v 1.6 2018/01/11 21:09:26 rpe Exp $ daemon="/usr/sbin/ypserv" . /etc/rc.d/rc.subr rc_pre() { - [ X"`domainname`" != X"" -a -d /var/yp/`domainname` ] + [[ -n $(domainname) && -d /var/yp/$(domainname) ]] } rc_cmd $1 -- 2.20.1