cli/env: fix whitelist not shadowing blacklist

If an ENVVAR was in the blacklist, it was omitted even if it matched a
whitelist rule.
This commit is contained in:
Henrik Lissner 2021-04-25 18:36:54 -04:00
parent 9d643b14ed
commit 44a501911b

View file

@ -124,12 +124,14 @@ default, on Linux, this is '$SHELL -ic /usr/bin/env'. Variables in
(whitelist (remq nil (append whitelist doom-env-whitelist))))
(insert "(")
(dolist (env doom--initial-process-environment)
(catch 'skip
(let* ((var (car (split-string env "=")))
(pred (doom-rpartial #'string-match-p var)))
(if (seq-find pred blacklist)
(doom-log "Ignoring %s" var)
(when (seq-find pred whitelist)
(doom-log "Whitelisted %s" var))
(when (seq-find pred blacklist)
(if (seq-find pred whitelist)
(doom-log "Whitelisted %s" var)
(doom-log "Ignored %s" var)
(throw 'skip t)))
(insert (prin1-to-string env) "\n "))))
(insert ")"))
(print! (success "Successfully generated %S") (path env-file))