mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Tramp: Refactor environment variable filtering to a separate function
* lisp/net/tramp.el (tramp-local-environment-variable-p): New function. (Bug#79413) (tramp-handle-make-process): * lisp/net/tramp-sh.el (tramp-sh-handle-make-process) (tramp-sh-handle-process-file): * lisp/net/tramp-androidsu.el (tramp-androidsu-handle-make-process): Use `tramp-local-environment-variable-p'.
This commit is contained in:
parent
26ad23addb
commit
e41eae39ad
3 changed files with 16 additions and 9 deletions
|
|
@ -311,9 +311,7 @@ FUNCTION."
|
||||||
(when
|
(when
|
||||||
(and
|
(and
|
||||||
(string-search "=" elt)
|
(string-search "=" elt)
|
||||||
(not
|
(not (tramp-local-environment-variable-p elt)))
|
||||||
(member
|
|
||||||
elt (default-toplevel-value 'process-environment))))
|
|
||||||
(setq env (cons elt env)))))
|
(setq env (cons elt env)))))
|
||||||
;; Add remote path if exists.
|
;; Add remote path if exists.
|
||||||
(env (let ((remote-path (string-join (tramp-get-remote-path v) ":")))
|
(env (let ((remote-path (string-join (tramp-get-remote-path v) ":")))
|
||||||
|
|
|
||||||
|
|
@ -3052,8 +3052,7 @@ will be used."
|
||||||
;; `process-environment'.
|
;; `process-environment'.
|
||||||
env uenv
|
env uenv
|
||||||
(env (dolist (elt (cons prompt process-environment) env)
|
(env (dolist (elt (cons prompt process-environment) env)
|
||||||
(or (member
|
(or (tramp-local-environment-variable-p elt)
|
||||||
elt (default-toplevel-value 'process-environment))
|
|
||||||
(if (string-search "=" elt)
|
(if (string-search "=" elt)
|
||||||
(setq env (append env `(,elt)))
|
(setq env (append env `(,elt)))
|
||||||
(setq uenv (cons elt uenv))))))
|
(setq uenv (cons elt uenv))))))
|
||||||
|
|
@ -3288,7 +3287,7 @@ will be used."
|
||||||
(cons program args) " "))
|
(cons program args) " "))
|
||||||
;; We use as environment the difference to toplevel `process-environment'.
|
;; We use as environment the difference to toplevel `process-environment'.
|
||||||
(dolist (elt process-environment)
|
(dolist (elt process-environment)
|
||||||
(or (member elt (default-toplevel-value 'process-environment))
|
(or (tramp-local-environment-variable-p elt)
|
||||||
(if (string-search "=" elt)
|
(if (string-search "=" elt)
|
||||||
(setq env (append env `(,elt)))
|
(setq env (append env `(,elt)))
|
||||||
(setq uenv (cons elt uenv)))))
|
(setq uenv (cons elt uenv)))))
|
||||||
|
|
|
||||||
|
|
@ -5347,6 +5347,18 @@ should be set connection-local.")
|
||||||
(or (not (stringp buffer)) (not (tramp-tramp-file-p buffer)))
|
(or (not (stringp buffer)) (not (tramp-tramp-file-p buffer)))
|
||||||
(or (not (stringp stderr)) (not (tramp-tramp-file-p stderr))))))
|
(or (not (stringp stderr)) (not (tramp-tramp-file-p stderr))))))
|
||||||
|
|
||||||
|
;; This function is used by tramp-*-handle-make-process and
|
||||||
|
;; tramp-sh-handle-process-file to filter local environment variables
|
||||||
|
;; that should not be propagated remotely. Users can override this
|
||||||
|
;; function if necessary, for example, to ensure that a specific
|
||||||
|
;; environment variable is applied to remote processes, whether it
|
||||||
|
;; exists locally or not.
|
||||||
|
(defun tramp-local-environment-variable-p (arg)
|
||||||
|
"Return non-nil if ARG exists in default `process-environment'.
|
||||||
|
Tramp does not propagate local environment variables in remote
|
||||||
|
processes."
|
||||||
|
(member arg (default-toplevel-value 'process-environment)))
|
||||||
|
|
||||||
(defun tramp-handle-make-process (&rest args)
|
(defun tramp-handle-make-process (&rest args)
|
||||||
"An alternative `make-process' implementation for Tramp files."
|
"An alternative `make-process' implementation for Tramp files."
|
||||||
(tramp-skeleton-make-process args nil nil
|
(tramp-skeleton-make-process args nil nil
|
||||||
|
|
@ -5365,9 +5377,7 @@ should be set connection-local.")
|
||||||
(env (dolist (elt process-environment env)
|
(env (dolist (elt process-environment env)
|
||||||
(when (and
|
(when (and
|
||||||
(string-search "=" elt)
|
(string-search "=" elt)
|
||||||
(not
|
(not (tramp-local-environment-variable-p elt)))
|
||||||
(member
|
|
||||||
elt (default-toplevel-value 'process-environment))))
|
|
||||||
(setq env (cons elt env)))))
|
(setq env (cons elt env)))))
|
||||||
;; Add remote path if exists.
|
;; Add remote path if exists.
|
||||||
(env (if-let* ((sh-file-name-handler-p)
|
(env (if-let* ((sh-file-name-handler-p)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue