Fix issue where extract-vars-from-env-file was popping up buffers

This commit is contained in:
Jeremy Dormitzer 2020-04-16 11:53:52 -04:00
parent ecf1be46fb
commit 056ff2384a

View File

@ -519,12 +519,14 @@ Load environment variables into Emacs from a shell script:
(cl-defun extract-vars-from-env-file (file &key dir)
"Extracts an alist of variable name to value from
a bash script that exports environment variables."
(let ((var-re "\\(.+?\\)=\\(.+\\)$")
(let ((file (expand-file-name file))
(var-re "\\(.+?\\)=\\(.+\\)$")
(env '()))
(with-temp-buffer
(cd (expand-file-name (or dir (file-name-directory file))))
(shell-command (concat "source " file " > /dev/null && env")
(current-buffer))
(insert (shell-command-to-string (concat "source "
(shell-quote-argument file)
" > /dev/null && env")))
(goto-char (point-min))
(save-match-data
(while (re-search-forward var-re nil t)