summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-08-25 14:29:18 +0000
committerschwarze <schwarze@openbsd.org>2014-08-25 14:29:18 +0000
commit27c2bc5523957f815f92cc0ae3d0bc912f047a03 (patch)
treeaa2af29ca9d08fdb9a87ff8ece0c845e8640d6e7
parentAdd a generic system-wide /usr/share/misc/mime.types file that can be (diff)
downloadwireguard-openbsd-27c2bc5523957f815f92cc0ae3d0bc912f047a03.tar.xz
wireguard-openbsd-27c2bc5523957f815f92cc0ae3d0bc912f047a03.zip
Simplify rm_from_pkg_scripts(); minus ten lines; no functional change;
ok ajacoutot@. For non-trivial automated text editing in sh(1), thou shalt use sed(1).
-rw-r--r--usr.sbin/rcctl/rcctl.sh18
1 files changed, 4 insertions, 14 deletions
diff --git a/usr.sbin/rcctl/rcctl.sh b/usr.sbin/rcctl/rcctl.sh
index cb7fa4fa86c..2bfe719390f 100644
--- a/usr.sbin/rcctl/rcctl.sh
+++ b/usr.sbin/rcctl/rcctl.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $OpenBSD: rcctl.sh,v 1.21 2014/08/25 07:35:37 ajacoutot Exp $
+# $OpenBSD: rcctl.sh,v 1.22 2014/08/25 14:29:18 schwarze Exp $
#
# Copyright (c) 2014 Antoine Jacoutot <ajacoutot@openbsd.org>
#
@@ -164,25 +164,15 @@ append_to_pkg_scripts()
rm_from_pkg_scripts()
{
- local _i _pkg_scripts
local _svc=$1
[ -n "${_svc}" ] || return
[ -z "${pkg_scripts}" ] && return
- for _i in ${pkg_scripts}; do
- if [ ${_i} != ${_svc} ]; then
- _pkg_scripts="${_pkg_scripts} ${_i}"
- fi
- done
- pkg_scripts=$(printf ' %s' ${_pkg_scripts})
- pkg_scripts=${_pkg_scripts## }
-
rcconf_edit_begin
- grep -v "^pkg_scripts.*=" /etc/rc.conf.local >${_TMP_RCCONF}
- if [ -n "${pkg_scripts}" ]; then
- echo pkg_scripts="${pkg_scripts}" >>${_TMP_RCCONF}
- fi
+ sed "/^pkg_scripts[[:>:]]/{s/[[:<:]]${_svc}[[:>:]]//g
+ s/['\"]//g;s/ *= */=/;s/ */ /g;s/ $//;/=$/d;}" \
+ /etc/rc.conf.local >${_TMP_RCCONF}
rcconf_edit_end
}