Skip to content

Commit

Permalink
fix(core): correctly handle edge cases in +env-save
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Sep 13, 2023
1 parent 510c299 commit 6047d92
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion elisp/+minemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,11 @@ Works like `shell-command-to-string' with two differences:
(insert ";; Adding the rest of the environment variables\n")
(dolist (env-var env-vars)
(unless (cl-some (+apply-partially-right #'string-match-p (car env-var)) +env-deny-vars)
(insert (format "(setenv \"%s\" \"%s\")\n" (car env-var) (cdr env-var))))))
;; Correctly handle edge cases '\n' and '"'
(let ((value (string-replace "\n" "\\n" (string-replace "\"" "\\\"" (cdr env-var)))))
(insert (format "(setenv \"%s\" \"%s\")\n"
(car env-var)
(string-replace "\n" "\\n" value)))))))
(write-file +env-file)))

;;;###autoload
Expand Down

0 comments on commit 6047d92

Please sign in to comment.