Prevent illegal envvars causing bash syntax errors

This commit is contained in:
Henrik Lissner 2020-08-10 23:05:59 -04:00
parent 85b5103cd9
commit 050ac73789
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -175,14 +175,13 @@ COMMAND, and passes ARGS to it."
(coding-system-for-read 'utf-8)) (coding-system-for-read 'utf-8))
(with-temp-file post-script (with-temp-file post-script
(insert "#!/usr/bin/env sh\n" (insert "#!/usr/bin/env sh\n"
"[ -x \"$0\" ] && rm -f \"$0\"\n"
(save-match-data (save-match-data
(cl-loop for env in process-environment (cl-loop for env in process-environment
if (string-match "^\\([^=]+\\)=\\(.+\\)$" env) if (string-match "^\\([^ !@#$%^&*()=]+\\)=\\(.+\\)$" env)
concat (format "%s=%S\n" concat (format "%s=%S\n"
(match-string 1 env) (match-string 1 env)
(match-string 2 env)))) (match-string 2 env))))
"\n" "\n[ -x \"$0\" ] && rm -f \"$0\"\n"
(if (stringp lines) (if (stringp lines)
lines lines
(string-join (string-join