Index: libexec/rc/rc.subr =================================================================== --- libexec/rc/rc.subr +++ libexec/rc/rc.subr @@ -58,17 +58,26 @@ # --------- # list_vars pattern -# List vars matching pattern. +# List vars matching glob pattern. # list_vars() { - set | { while read LINE; do - var="${LINE%%=*}" + # Restore glob behavior on return: + local - + local IFS + local line + local var + + # Disable glob for unquoted 'for' expansion below + set -f + IFS=$'\n' + for line in $(set); do + var="${line%%=*}" case "$var" in - "$LINE"|*[!a-zA-Z0-9_]*) continue ;; - $1) echo $var + "$line"|*[!a-zA-Z0-9_]*) continue ;; + $1) echo $var esac - done; } + done } # set_rcvar [var] [defval] [desc]