Support $ENV in Tramp
* doc/misc/tramp.texi (Remote processes): Explain setting $ENV. * etc/NEWS: Explain the "ENV" environment variable in `tramp-remote-process-environment'. * lisp/net/tramp-sh.el (tramp-remote-process-environment): Add "ENV=''". (tramp-open-shell): Read $ENV value from `tramp-remote-process-environment'. (tramp-open-connection-setup-interactive-shell): Set values in proper order.
This commit is contained in:
parent
e09dc1112b
commit
5126b7d6c2
3 changed files with 29 additions and 15 deletions
|
@ -2369,9 +2369,9 @@ program's environment for the remote host.
|
|||
structured similar to @code{process-environment}, where each element
|
||||
is a string of the form @samp{ENVVARNAME=VALUE}.
|
||||
|
||||
To avoid any conflicts with local host variables set through local
|
||||
configuration files, such as @file{~/.profile}, use @samp{ENVVARNAME=}
|
||||
to unset them for the remote environment.
|
||||
To avoid any conflicts with local host environment variables set
|
||||
through local configuration files, such as @file{~/.profile}, use
|
||||
@samp{ENVVARNAME=} to unset them for the remote environment.
|
||||
|
||||
@noindent
|
||||
Use @code{add-to-list} to add entries:
|
||||
|
@ -2383,8 +2383,8 @@ Use @code{add-to-list} to add entries:
|
|||
Modifying or deleting already existing values in the
|
||||
@code{tramp-remote-process-environment} list may not be feasible on
|
||||
restricted remote hosts. For example, some system administrators
|
||||
disallow changing @env{HISTORY} variable. To accommodate such
|
||||
restrictions when using @value{tramp}, fix the
|
||||
disallow changing @env{HISTORY} environment variable. To accommodate
|
||||
such restrictions when using @value{tramp}, fix the
|
||||
@code{tramp-remote-process-environment} by the following code in the
|
||||
local @file{.emacs} file:
|
||||
|
||||
|
@ -2394,6 +2394,16 @@ local @file{.emacs} file:
|
|||
(setq tramp-remote-process-environment process-environment))
|
||||
@end lisp
|
||||
|
||||
Setting the @env{ENV} environment variable instructs some shells to
|
||||
read an initialization file. Per default, @value{tramp} has disabled
|
||||
this. You could overwrite this behaviour by evaluating
|
||||
|
||||
@lisp
|
||||
(let ((process-environment tramp-remote-process-environment))
|
||||
(setenv "ENV" "$HOME/.profile")
|
||||
(setq tramp-remote-process-environment process-environment))
|
||||
@end lisp
|
||||
|
||||
@value{tramp} does not use the defaults specified in
|
||||
@code{process-environment} for running @code{process-file} or
|
||||
@code{start-file-process} on remote hosts. When values from
|
||||
|
|
4
etc/NEWS
4
etc/NEWS
|
@ -358,6 +358,10 @@ different group ID.
|
|||
*** New connection method "gdrive", which allows to access Google
|
||||
Drive onsite repositories.
|
||||
|
||||
+++
|
||||
Setting the "ENV" environment variable in `tramp-remote-process-environment'
|
||||
enables reading of shell initialization files.
|
||||
|
||||
---
|
||||
** 'auto-revert-use-notify' is set back to t in 'global-auto-revert-mode'.
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ the list by the special value `tramp-own-remote-path'."
|
|||
|
||||
;;;###tramp-autoload
|
||||
(defcustom tramp-remote-process-environment
|
||||
`("TMOUT=0" "LC_CTYPE=''"
|
||||
`("ENV=''" "TMOUT=0" "LC_CTYPE=''"
|
||||
,(format "TERM=%s" tramp-terminal-type)
|
||||
,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version)
|
||||
"CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat"
|
||||
|
@ -560,7 +560,7 @@ which might have been set in the init files like ~/.profile.
|
|||
Special handling is applied to the PATH environment, which should
|
||||
not be set here. Instead, it should be set via `tramp-remote-path'."
|
||||
:group 'tramp
|
||||
:version "24.4"
|
||||
:version "25.2"
|
||||
:type '(repeat string))
|
||||
|
||||
;;;###tramp-autoload
|
||||
|
@ -3935,7 +3935,8 @@ file exists and nonzero exit status otherwise."
|
|||
;; $HISTFILE is set according to `tramp-histfile-override'.
|
||||
(tramp-send-command
|
||||
vec (format
|
||||
"exec env ENV='' %s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s"
|
||||
"exec env ENV=%s %s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s"
|
||||
(or (getenv-internal "ENV" tramp-remote-process-environment) "")
|
||||
(if (stringp tramp-histfile-override)
|
||||
(format "HISTFILE=%s"
|
||||
(tramp-shell-quote-argument tramp-histfile-override))
|
||||
|
@ -4153,16 +4154,15 @@ process to set up. VEC specifies the connection."
|
|||
;; Set the environment.
|
||||
(tramp-message vec 5 "Setting default environment")
|
||||
|
||||
(let ((env (append `(,(tramp-get-remote-locale vec))
|
||||
(copy-sequence tramp-remote-process-environment)))
|
||||
unset vars item)
|
||||
(while env
|
||||
(setq item (split-string (car env) "=" 'omit))
|
||||
(let (unset vars)
|
||||
(dolist (item (reverse
|
||||
(append `(,(tramp-get-remote-locale vec))
|
||||
(copy-sequence tramp-remote-process-environment))))
|
||||
(setq item (split-string item "=" 'omit))
|
||||
(setcdr item (mapconcat 'identity (cdr item) "="))
|
||||
(if (and (stringp (cdr item)) (not (string-equal (cdr item) "")))
|
||||
(push (format "%s %s" (car item) (cdr item)) vars)
|
||||
(push (car item) unset))
|
||||
(setq env (cdr env)))
|
||||
(push (car item) unset)))
|
||||
(when vars
|
||||
(tramp-send-command
|
||||
vec
|
||||
|
|
Loading…
Add table
Reference in a new issue