From 0ed2b95dbaac493b37fa490ff9279e5c7c696d1d Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 6 Aug 2022 14:21:23 +0200 Subject: [PATCH] refactor(cli): include envvars in _doomrun debug logs --- lisp/doom-cli-lib.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lisp/doom-cli-lib.el b/lisp/doom-cli-lib.el index 309a1fa88..93c0fd8d0 100644 --- a/lisp/doom-cli-lib.el +++ b/lisp/doom-cli-lib.el @@ -1102,21 +1102,22 @@ Emacs' batch library lacks an implementation of the exec system call." (setenv "__DOOMCONTEXT" context-file) (make-directory (file-name-directory script-file) t) (let ((coding-system-for-write 'utf-8-auto) - (persistent-files (combine-and-quote-strings (delq nil (list script-file context-file))))) + (persistent-files (combine-and-quote-strings (delq nil (list script-file context-file)))) + (env (save-match-data + (cl-loop with initial-env = (get 'process-environment 'initial-value) + for env in (seq-difference process-environment initial-env) + if (string-match "^\\([a-zA-Z0-9_][^=]+\\)=\\(.+\\)$" env) + collect (format "%s=%s" + (match-string 1 env) + (shell-quote-argument (match-string 2 env))))))) (with-temp-file script-file - (doom-log "_doomrun: %s" command) + (doom-log "_doomrun: %s %s" (string-join env " ") command) (doom-log "_doomcleanup: %s" persistent-files) (insert "#!/usr/bin/env sh\n" "trap _doomcleanup EXIT\n" "_doomcleanup() {\n rm -f " persistent-files "\n}\n" "_doomrun() {\n " command "\n}\n" - (save-match-data - (cl-loop with initial-env = (get 'process-environment 'initial-value) - for env in (seq-difference process-environment initial-env) - if (string-match "^\\([a-zA-Z0-9_]+\\|__DOOM[^=]+\\)=\\(.+\\)$" env) - concat (format "%s=%s \\\n" - (match-string 1 env) - (shell-quote-argument (match-string 2 env))))) + (string-join env " \\\n") (format "PATH=\"%s%s$PATH\" \\\n" (doom-path doom-emacs-dir "bin") path-separator)