Fix #2046 replacing process-environment, exec-path & shell-file-name

This commit is contained in:
Henrik Lissner 2019-11-21 17:14:10 -05:00
parent cc793f323f
commit a6e25209b8
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 16 additions and 9 deletions

View file

@ -417,12 +417,13 @@ in interactive sessions, nil otherwise (but logs a warning)."
(if (not (file-readable-p file)) (if (not (file-readable-p file))
(unless noerror (unless noerror
(signal 'file-error (list "Couldn't read envvar file" file))) (signal 'file-error (list "Couldn't read envvar file" file)))
(let (environment) (let (envvars environment)
(with-temp-buffer (with-temp-buffer
(save-excursion (save-excursion
(insert "\n") (insert "\n")
(insert-file-contents file)) (insert-file-contents file))
(while (re-search-forward "\n *\\([^#= \n]*\\)=" nil t) (while (re-search-forward "\n *\\([^#= \n]*\\)=" nil t)
(push (match-string 1) envvars)
(push (buffer-substring (push (buffer-substring
(match-beginning 1) (match-beginning 1)
(1- (or (save-excursion (1- (or (save-excursion
@ -431,13 +432,19 @@ in interactive sessions, nil otherwise (but logs a warning)."
(point-max)))) (point-max))))
environment))) environment)))
(when environment (when environment
(setq-default (setq process-environment
process-environment (nreverse environment) (append (nreverse environment) process-environment)
exec-path (append (parse-colon-path (getenv "PATH")) exec-path
(if (member "PATH" envvars)
(append (parse-colon-path (getenv "PATH"))
(list exec-directory)) (list exec-directory))
shell-file-name (or (getenv "SHELL") exec-path)
shell-file-name
(if (member "SHELL" envvars)
(setq shell-file-name
(or (getenv "SHELL") shell-file-name))
shell-file-name)) shell-file-name))
process-environment)))) envvars))))
(defun doom-initialize (&optional force-p) (defun doom-initialize (&optional force-p)
"Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil). "Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil).

View file

@ -117,7 +117,7 @@
(it "returns the new value for `process-environment'" (it "returns the new value for `process-environment'"
(expect (doom-load-envvars-file doom-env-file) (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" (it "alters environment variables"
(dolist (key '("A" "B" "C")) (dolist (key '("A" "B" "C"))