emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/exec-path-from-shell 4223b12cf9 004/114: Extract PATH via


From: ELPA Syncer
Subject: [nongnu] elpa/exec-path-from-shell 4223b12cf9 004/114: Extract PATH via marker
Date: Tue, 5 Sep 2023 03:59:56 -0400 (EDT)

branch: elpa/exec-path-from-shell
commit 4223b12cf9cec9d5f5ad9a429ab7c081df77bec6
Author: Sebastian Wiesner <lunaryorn@gmail.com>
Commit: Sebastian Wiesner <lunaryorn@gmail.com>

    Extract PATH via marker
    
    An interactive shell may have additional output depending on the user's 
shell
    configuration.  Insert a marker and extract the value via this marker to 
make
    sure that only the actual "$PATH" content is returned.
---
 exec-path-from-shell.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/exec-path-from-shell.el b/exec-path-from-shell.el
index e0f3fd72c3..f68251cfc3 100644
--- a/exec-path-from-shell.el
+++ b/exec-path-from-shell.el
@@ -57,9 +57,11 @@
 ;;; Code:
 
 (defun exec-path-from-shell-getenv (name)
-  (replace-regexp-in-string
-   "[ \t\n]*$" ""
-   (shell-command-to-string (format "$SHELL --login -i -c 'echo $%s'" name))))
+  (with-temp-buffer
+    (call-process (getenv "SHELL") nil (current-buffer) nil
+                  "--login" "-i" "-c" (concat "echo __RESULT=$" name))
+    (when (re-search-backward "__RESULT=\\(.*\\)" nil t)
+      (match-string 1))))
 
 ;;;###autoload
 (defun exec-path-from-shell-copy-env (name)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]