branch: elpa/exec-path-from-shell
commit b0449230d8c89bbdd7715c5229f1890d71c40d46
Author: Steve Purcell <[email protected]>
Commit: Steve Purcell <[email protected]>

    Distinguish between empty ("") and unset env vars
    
    Fixes #31
---
 exec-path-from-shell.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/exec-path-from-shell.el b/exec-path-from-shell.el
index ab59789f1c..4114aedebe 100644
--- a/exec-path-from-shell.el
+++ b/exec-path-from-shell.el
@@ -148,14 +148,19 @@ shell-escaped, so they may contain $ etc."
 
 Execute $SHELL according to `exec-path-from-shell-arguments'.
 The result is a list of (NAME . VALUE) pairs."
-  (let* ((dollar-names (mapcar (lambda (n) (format "${%s-}" n)) names))
+  (let* ((random-default (md5 (format "%s%s%s" (emacs-pid) (random) 
(current-time))))
+         (dollar-names (mapcar (lambda (n) (format "${%s:-%s}" n 
random-default)) names))
          (values (split-string (exec-path-from-shell-printf
                                 (mapconcat #'identity (make-list (length 
names) "%s") "\\000")
                                 dollar-names) "\0")))
     (let (result)
       (while names
         (prog1
-            (push (cons (car names) (car values)) result)
+            (let ((value (car values)))
+              (push (cons (car names)
+                          (unless (string-equal random-default value)
+                            value))
+                    result))
           (setq values (cdr values)
                 names (cdr names))))
       result)))

Reply via email to