aboutsummaryrefslogtreecommitdiff
path: root/libexec/rc
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2018-12-11 01:38:50 +0000
committerConrad Meyer <cem@FreeBSD.org>2018-12-11 01:38:50 +0000
commitb2b1708d5991878d6205ab1a1cae5762d956f129 (patch)
tree87f1b238d396e438cd87daac7b9d8fa35cc747fa /libexec/rc
parentc1745bf5036da58631cce53d78c9b3a09d648ddf (diff)
Notes
Diffstat (limited to 'libexec/rc')
-rw-r--r--libexec/rc/rc.subr26
1 files changed, 19 insertions, 7 deletions
diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 072eda2cebf65..6688438360f97 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -58,17 +58,29 @@ JID=0
# ---------
# list_vars pattern
-# List vars matching pattern.
+# List variables matching glob pattern.
#
list_vars()
{
- set | { while read LINE; do
- var="${LINE%%=*}"
- case "$var" in
- "$LINE"|*[!a-zA-Z0-9_]*) continue ;;
- $1) echo $var
+ # Localize 'set' option below.
+ local -
+ local IFS=$'\n' line varname
+
+ # Disable path expansion in unquoted 'for' parameters below.
+ set -o noglob
+
+ for line in $(set); do
+ varname="${line%%=*}"
+
+ case "$varname" in
+ "$line"|*[!a-zA-Z0-9_]*)
+ continue
+ ;;
+ $1)
+ echo $varname
+ ;;
esac
- done; }
+ done
}
# set_rcvar [var] [defval] [desc]