From 8402f8aecc322df7bf084334c122d0b15f2df948 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 19 Aug 2020 13:56:11 -0400 Subject: [PATCH] Fix #3781 (part 2): error reading from stdin Possibly addresses #3746 --- core/core-cli.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/core-cli.el b/core/core-cli.el index 3d263c4d3..94089315a 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -171,19 +171,11 @@ 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) - (delimiter "__EOF__")) + (coding-system-for-write 'utf-8-unix) + (coding-system-for-read 'utf-8-unix)) (with-temp-file post-script (insert "#!/usr/bin/env sh\n" - (save-match-data - (cl-loop for env in process-environment - if (string-match "^\\([a-zA-Z0-9_]+\\)=\\(.+\\)$" env) - concat (format "%s=%s \\\n" - (match-string 1 env) - (shell-quote-argument (match-string 2 env))))) - (format "PATH=\"%s:$PATH\" \\\n" (concat doom-emacs-dir "bin/")) - "/usr/bin/env sh <<" delimiter "\n" + "_postscript() {\n" "rm -f " (shell-quote-argument post-script) "\n" (if (stringp lines) lines @@ -193,7 +185,15 @@ COMMAND, and passes ARGS to it." collect (mapconcat #'shell-quote-argument (remq nil line) " ")) (list (mapconcat #'shell-quote-argument (remq nil lines) " "))) "\n")) - "\n" delimiter "\n")) + "\n}\n" + (save-match-data + (cl-loop for env in process-environment + if (string-match "^\\([a-zA-Z0-9_]+\\)=\\(.+\\)$" env) + concat (format "%s=%s \\\n" + (match-string 1 env) + (shell-quote-argument (match-string 2 env))))) + (format "PATH=\"%s:$PATH\" \\\n" (concat doom-emacs-dir "bin/")) + "_postscript $@\n")) (set-file-modes post-script #o700))) (defun doom-cli-execute-lines-after (&rest lines)