summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
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