diff --git a/emacs/init.org b/emacs/init.org index 78f98cf..0b52264 100755 --- a/emacs/init.org +++ b/emacs/init.org @@ -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)