Fix #2046 replacing process-environment, exec-path & shell-file-name
This commit is contained in:
parent
cc793f323f
commit
a6e25209b8
2 changed files with 16 additions and 9 deletions
23
core/core.el
23
core/core.el
|
@ -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
|
||||||
(list exec-directory))
|
(if (member "PATH" envvars)
|
||||||
shell-file-name (or (getenv "SHELL")
|
(append (parse-colon-path (getenv "PATH"))
|
||||||
shell-file-name))
|
(list exec-directory))
|
||||||
process-environment))))
|
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)
|
(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).
|
||||||
|
|
|
@ -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"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue