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 bfaa02106e 031/114: [Fix #13] Make sh


From: ELPA Syncer
Subject: [nongnu] elpa/exec-path-from-shell bfaa02106e 031/114: [Fix #13] Make shell arguments customizable
Date: Tue, 5 Sep 2023 03:59:58 -0400 (EDT)

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

    [Fix #13] Make shell arguments customizable
---
 exec-path-from-shell.el | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/exec-path-from-shell.el b/exec-path-from-shell.el
index 4bb5383bfb..5d3f3851e6 100644
--- a/exec-path-from-shell.el
+++ b/exec-path-from-shell.el
@@ -84,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.
 
@@ -100,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)))))
@@ -113,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]