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 63a88bfb4f 055/114: Warn users if the


From: ELPA Syncer
Subject: [nongnu] elpa/exec-path-from-shell 63a88bfb4f 055/114: Warn users if the "-i" arg makes a difference given their startup files
Date: Tue, 5 Sep 2023 04:00:00 -0400 (EDT)

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

    Warn users if the "-i" arg makes a difference given their startup files
---
 exec-path-from-shell.el | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/exec-path-from-shell.el b/exec-path-from-shell.el
index 1847c678c8..a1f656b4d6 100644
--- a/exec-path-from-shell.el
+++ b/exec-path-from-shell.el
@@ -188,9 +188,19 @@ variables such as `exec-path'."
 As a special case, if the variable is $PATH, then `exec-path' and
 `eshell-path-env' are also set appropriately.  The result is an alist,
 as described by `exec-path-from-shell-getenvs'."
-  (mapc (lambda (pair)
-          (exec-path-from-shell-setenv (car pair) (cdr pair)))
-        (exec-path-from-shell-getenvs names)))
+  (let ((pairs (exec-path-from-shell-getenvs names))
+        (without-minus-i (remove "-i" exec-path-from-shell-arguments)))
+
+    ;; If the user is using "-i", we warn them if it is necessary.
+    (unless (eq exec-path-from-shell-arguments without-minus-i)
+      (let* ((exec-path-from-shell-arguments without-minus-i)
+             (alt-pairs (exec-path-from-shell-getenvs names)))
+        (unless (equal pairs alt-pairs)
+          (warn "You appear to be setting environment variables in your 
.bashrc or .zshrc: those files are only read by interactive shells, so you 
should instead set environment variables in startup files like .bash_profile or 
.zshenv.  See the man page for your shell for more info.  In future, 
exec-path-from-shell will not read variables set in the wrong files."))))
+
+    (mapc (lambda (pair)
+            (exec-path-from-shell-setenv (car pair) (cdr pair)))
+          pairs)))
 
 ;;;###autoload
 (defun exec-path-from-shell-copy-env (name)



reply via email to

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