diff --git a/core/core-cli.el b/core/core-cli.el index 2e31515d1..a8cc89ab5 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -172,17 +172,18 @@ COMMAND, and passes ARGS to it." (defun doom-cli--execute-after (lines) (let ((post-script (concat doom-local-dir ".doom.sh")) (coding-system-for-write 'utf-8) - (coding-system-for-read 'utf-8)) + (coding-system-for-read 'utf-8) + (delimiter "--%EOF%--")) (with-temp-file post-script - (insert "#!/usr/bin/env sh\n" - (save-match-data + (insert (save-match-data (cl-loop for env in process-environment if (string-match "^\\([a-zA-Z0-9_]+\\)=\\(.+\\)$" env) - concat (format "export %s=%s;\n" + concat (format "%s=%s \\\n" (match-string 1 env) (shell-quote-argument (match-string 2 env))))) - (format "\nexport PATH=\"%s:$PATH\"\n" (concat doom-emacs-dir "bin/")) - "\n[ -x \"$0\" ] && rm -f \"$0\"\n" + (format "PATH=\"%s:$PATH\" \\\n" (concat doom-emacs-dir "bin/")) + "/usr/bin/env sh <<" delimiter "\n" + "rm -f " (shell-quote-argument post-script) "\n" (if (stringp lines) lines (string-join @@ -191,7 +192,7 @@ COMMAND, and passes ARGS to it." collect (mapconcat #'shell-quote-argument (remq nil line) " ")) (list (mapconcat #'shell-quote-argument (remq nil lines) " "))) "\n")) - "\n")) + "\n" delimiter "\n")) (set-file-modes post-script #o700))) (defun doom-cli-execute-lines-after (&rest lines)