summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorkhorben <khorben@pkgsrc.org>2021-08-30 21:45:02 +0000
committerkhorben <khorben@pkgsrc.org>2021-08-30 21:45:02 +0000
commit5e2ad1977aef4d001e5cdba3dde5fd4959333e75 (patch)
treec758a752c72b2cb2d64331755b7f61e8113cd3b6 /pkgtools
parent0567bf3716629dabf7805c0ed9556d82ece3d31f (diff)
downloadpkgsrc-5e2ad1977aef4d001e5cdba3dde5fd4959333e75.tar.gz
rc.subr: update to version 20210830
This introduces the function load_rc_config_var(), as provided by NetBSD's own rc.subr. Tested on NetBSD/amd64 (unprivileged).
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/rc.subr/Makefile4
-rw-r--r--pkgtools/rc.subr/files/rc.subr21
2 files changed, 22 insertions, 3 deletions
diff --git a/pkgtools/rc.subr/Makefile b/pkgtools/rc.subr/Makefile
index 8dccff5b240..0f7a027c899 100644
--- a/pkgtools/rc.subr/Makefile
+++ b/pkgtools/rc.subr/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.35 2021/05/30 23:46:26 khorben Exp $
+# $NetBSD: Makefile,v 1.36 2021/08/30 21:45:02 khorben Exp $
#
-PKGNAME= rc.subr-20210517
+PKGNAME= rc.subr-20210830
CATEGORIES= pkgtools
MAINTAINER= sbd@NetBSD.org
diff --git a/pkgtools/rc.subr/files/rc.subr b/pkgtools/rc.subr/files/rc.subr
index 822c51caa40..93f7323ac6b 100644
--- a/pkgtools/rc.subr/files/rc.subr
+++ b/pkgtools/rc.subr/files/rc.subr
@@ -1,4 +1,4 @@
-# $NetBSD: rc.subr,v 1.17 2021/05/30 23:46:26 khorben Exp $
+# $NetBSD: rc.subr,v 1.18 2021/08/30 21:45:02 khorben Exp $
#
# Copyright (c) 1997-2002 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -869,6 +869,25 @@ load_rc_config()
fi
}
+#
+# load_rc_config_var cmd var
+# Read the rc.conf(5) var for cmd and set in the
+# current shell, using load_rc_config in a subshell to prevent
+# unwanted side effects from other variable assignments.
+#
+load_rc_config_var()
+{
+ if [ $# -ne 2 ]; then
+ err 3 'USAGE: load_rc_config_var cmd var'
+ fi
+ eval $(eval '(
+ load_rc_config '$1' >/dev/null;
+ if [ -n "${'$2'}" ] || [ "${'$2'-UNSET}" != "UNSET" ]; then
+ echo '$2'=\'\''${'$2'}\'\'';
+ fi
+ )' )
+}
+
#
# rc_usage commands