From 6af65dfd64203d8df1a88df379cb02aa4b9c4a03 Mon Sep 17 00:00:00 2001 From: Antoine Jacoutot Date: Sun, 19 Jun 2016 15:00:38 +0000 Subject: Replace some expensive evals. --- usr.sbin/rcctl/rcctl.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'usr.sbin/rcctl') diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh index b66a26dea90..48d250bdeed 100644 --- a/usr.sbin/rcctl/rcctl.sh +++ b/usr.sbin/rcctl/rcctl.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: rcctl.sh,v 1.101 2016/06/19 11:32:25 ajacoutot Exp $ +# $OpenBSD: rcctl.sh,v 1.102 2016/06/19 15:00:37 ajacoutot Exp $ # # Copyright (c) 2014, 2015 Antoine Jacoutot # Copyright (c) 2014 Ingo Schwarze @@ -150,13 +150,16 @@ svc_is_base() local _svc=$1 [ -n "${_svc}" ] || return - local _cached=$(eval echo \${cached_svc_is_base_${_svc}}) + local _cached _ret + + _cached=$(eval echo \${cached_svc_is_base_${_svc}}) [ "${_cached}" ] && return "${_cached}" grep -qw "^${_svc}_flags" /etc/rc.conf + _ret=$? - eval cached_svc_is_base_${_svc}=$? - eval return \${cached_svc_is_base_${_svc}} + set -A cached_svc_is_base_${_svc} -- ${_ret} + return ${_ret} } svc_is_meta() @@ -164,13 +167,16 @@ svc_is_meta() local _svc=$1 [ -n "${_svc}" ] || return - local _cached=$(eval echo \${cached_svc_is_meta_${_svc}}) + local _cached _ret + + _cached=$(eval echo \${cached_svc_is_meta_${_svc}}) [ "${_cached}" ] && return "${_cached}" [ -r "/etc/rc.d/${_svc}" ] && ! grep -qw "^rc_cmd" /etc/rc.d/${_svc} + _ret=$? - eval cached_svc_is_meta_${_svc}=$? - eval return \${cached_svc_is_meta_${_svc}} + set -A cached_svc_is_meta_${_svc} -- ${_ret} + return ${_ret} } svc_is_special() @@ -178,13 +184,16 @@ svc_is_special() local _svc=$1 [ -n "${_svc}" ] || return - local _cached=$(eval echo \${cached_svc_is_special_${_svc}}) + local _cached _ret + + _cached=$(eval echo \${cached_svc_is_special_${_svc}}) [ "${_cached}" ] && return "${_cached}" echo ${_special_svcs} | grep -qw -- ${_svc} + _ret=$? - eval cached_svc_is_special_${_svc}=$? - eval return \${cached_svc_is_special_${_svc}} + set -A cached_svc_is_special_${_svc} -- ${_ret} + return ${_ret} } svc_ls() -- cgit v1.2.3