diff --git a/core/core.el b/core/core.el index 093efc1d3..1a5130f18 100644 --- a/core/core.el +++ b/core/core.el @@ -417,12 +417,13 @@ in interactive sessions, nil otherwise (but logs a warning)." (if (not (file-readable-p file)) (unless noerror (signal 'file-error (list "Couldn't read envvar file" file))) - (let (environment) + (let (envvars environment) (with-temp-buffer (save-excursion (insert "\n") (insert-file-contents file)) (while (re-search-forward "\n *\\([^#= \n]*\\)=" nil t) + (push (match-string 1) envvars) (push (buffer-substring (match-beginning 1) (1- (or (save-excursion @@ -431,13 +432,19 @@ in interactive sessions, nil otherwise (but logs a warning)." (point-max)))) environment))) (when environment - (setq-default - process-environment (nreverse environment) - exec-path (append (parse-colon-path (getenv "PATH")) - (list exec-directory)) - shell-file-name (or (getenv "SHELL") - shell-file-name)) - process-environment)))) + (setq process-environment + (append (nreverse environment) process-environment) + exec-path + (if (member "PATH" envvars) + (append (parse-colon-path (getenv "PATH")) + (list exec-directory)) + exec-path) + shell-file-name + (if (member "SHELL" envvars) + (setq shell-file-name + (or (getenv "SHELL") shell-file-name)) + shell-file-name)) + envvars)))) (defun doom-initialize (&optional force-p) "Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil). diff --git a/core/test/test-core.el b/core/test/test-core.el index 0207390b4..6b9305c13 100644 --- a/core/test/test-core.el +++ b/core/test/test-core.el @@ -117,7 +117,7 @@ (it "returns the new value for `process-environment'" (expect (doom-load-envvars-file doom-env-file) - :to-equal '("A=1" "B=2" "C=3"))) + :to-have-same-items-as '("A" "B" "C"))) (it "alters environment variables" (dolist (key '("A" "B" "C"))