diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2016-06-19 11:32:26 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2016-06-19 11:32:26 +0000 |
commit | 0d73239ef48f976061a181d702567d59b3378b0a (patch) | |
tree | 729f90829bc1208e447813c0e5692db6c3f57968 | |
parent | 4525f9a62b8875e2561ef3c21d2825fed5ef6a5c (diff) |
Do caching differently.
-rw-r--r-- | usr.sbin/rcctl/rcctl.sh | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh index 27574b1f9d3..b66a26dea90 100644 --- a/usr.sbin/rcctl/rcctl.sh +++ b/usr.sbin/rcctl/rcctl.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: rcctl.sh,v 1.100 2016/06/19 11:14:20 ajacoutot Exp $ +# $OpenBSD: rcctl.sh,v 1.101 2016/06/19 11:32:25 ajacoutot Exp $ # # Copyright (c) 2014, 2015 Antoine Jacoutot <ajacoutot@openbsd.org> # Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -150,13 +150,13 @@ svc_is_base() local _svc=$1 [ -n "${_svc}" ] || return -# [ -n "${cached_svc_is_base[${_svc}]}" ] && \ -# return ${cached_svc_is_base[${_svc}]} + local _cached=$(eval echo \${cached_svc_is_base_${_svc}}) + [ "${_cached}" ] && return "${_cached}" grep -qw "^${_svc}_flags" /etc/rc.conf - cached_svc_is_base[${_svc}]=$? - return ${cached_svc_is_base[${_svc}]} + eval cached_svc_is_base_${_svc}=$? + eval return \${cached_svc_is_base_${_svc}} } svc_is_meta() @@ -164,13 +164,13 @@ svc_is_meta() local _svc=$1 [ -n "${_svc}" ] || return -# [ -n "${cached_svc_is_meta[${_svc}]}" ] && \ -# return ${cached_svc_is_meta[${_svc}]} + local _cached=$(eval echo \${cached_svc_is_meta_${_svc}}) + [ "${_cached}" ] && return "${_cached}" [ -r "/etc/rc.d/${_svc}" ] && ! grep -qw "^rc_cmd" /etc/rc.d/${_svc} - cached_svc_is_meta[${_svc}]=$? - return ${cached_svc_is_meta[${_svc}]} + eval cached_svc_is_meta_${_svc}=$? + eval return \${cached_svc_is_meta_${_svc}} } svc_is_special() @@ -178,13 +178,13 @@ svc_is_special() local _svc=$1 [ -n "${_svc}" ] || return -# [ -n "${cached_svc_is_special[${_svc}]}" ] && \ -# return ${cached_svc_is_special[${_svc}]} + local _cached=$(eval echo \${cached_svc_is_special_${_svc}}) + [ "${_cached}" ] && return "${_cached}" echo ${_special_svcs} | grep -qw -- ${_svc} - cached_svc_is_special[${_svc}]=$? - return ${cached_svc_is_special[${_svc}]} + eval cached_svc_is_special_${_svc}=$? + eval return \${cached_svc_is_special_${_svc}} } svc_ls() |