Skip to content

Commit

Permalink
Warn users if the "-i" arg makes a difference given their startup files
Browse files Browse the repository at this point in the history
  • Loading branch information
purcell committed Nov 20, 2015
1 parent 30c793b commit 63a88bf
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions exec-path-from-shell.el
Expand Up @@ -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)
Expand Down

0 comments on commit 63a88bf

Please sign in to comment.