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))
(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"))
(setq process-environment
(append (nreverse environment) process-environment)
exec-path
(if (member "PATH" envvars)
(append (parse-colon-path (getenv "PATH"))
(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))
process-environment))))
envvars))))
(defun doom-initialize (&optional force-p)
"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'"
(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"))