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 9def990ba4 069/114: Allow shell to be


From: ELPA Syncer
Subject: [nongnu] elpa/exec-path-from-shell 9def990ba4 069/114: Allow shell to be set explicitly, and change default resolution rules
Date: Tue, 5 Sep 2023 04:00:01 -0400 (EDT)

branch: elpa/exec-path-from-shell
commit 9def990ba4c30409a316d5cbf7b02296a394dece
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>

    Allow shell to be set explicitly, and change default resolution rules
    
    Fixes #59.
    
    The standard variable shell-file-name is now used by default, with
    $SHELL as a fallback. Both can also now be overridden by setting
    exec-path-from-shell-shell-name.
---
 exec-path-from-shell.el | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/exec-path-from-shell.el b/exec-path-from-shell.el
index f35b142d27..d9cd0a234f 100644
--- a/exec-path-from-shell.el
+++ b/exec-path-from-shell.el
@@ -90,6 +90,13 @@ Environment variables should be set in .profile or .zshenv 
rather than
   :type 'boolean
   :group 'exec-path-from-shell)
 
+(defcustom exec-path-from-shell-shell-name nil
+  "If non-nil, use this shell executable.
+Otherwise, use either `shell-file-name' (if set), or the value of
+the SHELL environment variable."
+  :type 'file
+  :group 'exec-path-from-shell)
+
 (defvar exec-path-from-shell-debug nil
   "Display debug info when non-nil.")
 
@@ -98,11 +105,16 @@ Environment variables should be set in .profile or .zshenv 
rather than
   (concat "\"" (replace-regexp-in-string "\"" "\\\\\"" s) "\""))
 
 (defun exec-path-from-shell--shell ()
-  "Return the shell to use."
-  (or (getenv "SHELL") (error "SHELL environment variable is unset")))
+  "Return the shell to use.
+See documentation for `exec-path-from-shell-shell-name'."
+  (or
+   exec-path-from-shell-shell-name
+   shell-file-name
+   (getenv "SHELL")
+   (error "SHELL environment variable is unset")))
 
 (defcustom exec-path-from-shell-arguments
-  (if (string-match-p "t?csh$" (or (getenv "SHELL") ""))
+  (if (string-match-p "t?csh$" (exec-path-from-shell--shell))
       (list "-d")
     (list "-l" "-i"))
   "Additional arguments to pass to the shell.
@@ -117,13 +129,13 @@ The default value denotes an interactive login shell."
     (apply 'message msg args)))
 
 (defun exec-path-from-shell--standard-shell-p (shell)
-  "Return non-nil iff SHELL supports the standard ${VAR-default} syntax."
+  "Return non-nil iff the shell supports the standard ${VAR-default} syntax."
   (not (string-match "\\(fish\\|t?csh\\)$" shell)))
 
 (defun exec-path-from-shell-printf (str &optional args)
   "Return the result of printing STR in the user's shell.
 
-Executes $SHELL as interactive login shell.
+Executes the shell as interactive login shell.
 
 STR is inserted literally in a single-quoted argument to printf,
 and may therefore contain backslashed escape sequences understood
@@ -158,7 +170,7 @@ 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 according to `exec-path-from-shell-arguments'.
+Execute the shell according to `exec-path-from-shell-arguments'.
 The result is a list of (NAME . VALUE) pairs."
   (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))
@@ -180,7 +192,7 @@ The result is a list of (NAME . VALUE) pairs."
 (defun exec-path-from-shell-getenv (name)
   "Get the environment variable NAME from the user's shell.
 
-Execute $SHELL as interactive login shell, have it output the
+Execute the shell as interactive login shell, have it output the
 variable of NAME and return this output as string."
   (cdr (assoc name (exec-path-from-shell-getenvs (list name)))))
 



reply via email to

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