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 a5162e6f99 032/114: Merge pull reques


From: ELPA Syncer
Subject: [nongnu] elpa/exec-path-from-shell a5162e6f99 032/114: Merge pull request #14 from lunaryorn/customizable-args
Date: Tue, 5 Sep 2023 03:59:58 -0400 (EDT)

branch: elpa/exec-path-from-shell
commit a5162e6f9935484fe87beb61f534a9935d4b7d92
Merge: 49219e9425 bfaa02106e
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>

    Merge pull request #14 from lunaryorn/customizable-args
    
    Customizable args
---
 exec-path-from-shell.el | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/exec-path-from-shell.el b/exec-path-from-shell.el
index 84d7c6a4c5..5d3f3851e6 100644
--- a/exec-path-from-shell.el
+++ b/exec-path-from-shell.el
@@ -70,6 +70,7 @@
 (defcustom exec-path-from-shell-variables
   '("PATH" "MANPATH")
   "List of environment variables which are copied from the shell."
+  :type '(repeat (string :tag "Environment variable"))
   :group 'exec-path-from-shell)
 
 (defun exec-path-from-shell--double-quote (s)
@@ -83,6 +84,14 @@
   "Return the name of the --login arg for SHELL."
   (if (exec-path-from-shell--tcsh-p shell) "-d" "-l"))
 
+(defcustom exec-path-from-shell-arguments
+  (list (exec-path-from-shell--login-arg (getenv "SHELL")) "-i")
+  "Additional arguments to pass to the shell.
+
+The default value denotes an interactive login shell."
+  :type '(repeat (string :tag "Shell argument"))
+  :group 'exec-path-from-shell)
+
 (defun exec-path-from-shell-printf (str &optional args)
   "Return the result of printing STR in the user's shell.
 
@@ -99,12 +108,12 @@ shell-escaped, so they may contain $ etc."
          (printf-command
           (concat printf-bin
                   " '__RESULT\\000" str "' "
-                  (mapconcat #'exec-path-from-shell--double-quote args " "))))
+                  (mapconcat #'exec-path-from-shell--double-quote args " ")))
+         (shell-args (append exec-path-from-shell-arguments
+                             (list "-c" printf-command))))
     (with-temp-buffer
-      (let ((shell (getenv "SHELL")))
-        (call-process shell nil (current-buffer) nil
-                      (exec-path-from-shell--login-arg shell)
-                      "-i" "-c" printf-command))
+      (apply #'call-process
+             (getenv "SHELL") nil (current-buffer) nil shell-args)
       (goto-char (point-min))
       (when (re-search-forward "__RESULT\0\\(.*\\)" nil t)
         (match-string 1)))))
@@ -112,8 +121,8 @@ shell-escaped, so they may contain $ etc."
 (defun exec-path-from-shell-getenvs (names)
   "Get the environment variables with NAMES from the user's shell.
 
-Execute $SHELL as interactive login shell.  The result is a list
-of (NAME . VALUE) pairs."
+Execute $SHELL according to `exec-path-from-shell-arguments'.
+The result is a list of (NAME . VALUE) pairs."
   (let* ((dollar-names (mapcar (lambda (n) (concat "$" n)) names))
          (values (if (exec-path-from-shell--tcsh-p (getenv "SHELL"))
                      ;; Dumb shell



reply via email to

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