branch: elpa/exec-path-from-shell
commit 2ae5088c2129c19be817f6ed894d218ca67d4ede
Author: Steve Purcell <[email protected]>
Commit: Steve Purcell <[email protected]>
Use printf instead of echo (thanks @bradleywright)
---
exec-path-from-shell.el | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/exec-path-from-shell.el b/exec-path-from-shell.el
index 21e1c83a67..f17c566978 100644
--- a/exec-path-from-shell.el
+++ b/exec-path-from-shell.el
@@ -66,14 +66,17 @@
"List of environment variables which are copied from the shell."
:group 'exec-path-from-shell)
-(defun exec-path-from-shell-echo (str)
- "Return the result of echoing STR in the user's shell.
+(defun exec-path-from-shell-printf (str)
+ "Return the result of printing STR in the user's shell.
-STR is inserted literally in a double-quoted argument to echo.
-Executes $SHELL as interactive login shell."
+Executes $SHELL as interactive login shell.
+
+STR is inserted literally in a double-quoted argument to printf,
+and may therefore contain backslashed escape sequences, but must not
+contain the '%' character."
(with-temp-buffer
(call-process (getenv "SHELL") nil (current-buffer) nil
- "--login" "-i" "-c" (concat "echo -e \"__RESULT\\0" str
"\""))
+ "--login" "-i" "-c" (concat "printf \"__RESULT\\0" str "\""))
(goto-char (point-min))
(when (re-search-forward "__RESULT\0\\(.*\\)" nil t)
(match-string 1))))
@@ -85,7 +88,7 @@ Execute $SHELL as interactive login shell. The result is a
list
of (NAME . VALUE) pairs."
(let ((values
(split-string
- (exec-path-from-shell-echo
+ (exec-path-from-shell-printf
(mapconcat (lambda (n) (concat "$" n)) names "\\0"))
"\0"))
result)