summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2016-08-09 11:50:13 +0200
committerMichael Albinus <michael.albinus@gmx.de>2016-08-09 11:50:13 +0200
commit5126b7d6c201f95fde0d817a64620d152c1c15e1 (patch)
treeccb14a980247a7df96f026ab65b5d320f5eae8a6
parente09dc1112b1f209d8141fc847edf23bd9cfa5ae1 (diff)
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.
-rw-r--r--doc/misc/tramp.texi20
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/net/tramp-sh.el20
3 files changed, 29 insertions, 15 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 2c41dddd1b..37518284bb 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index 0a202ccade..d62dcacbe9 100644
--- a/etc/NEWS
+++ b/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'.
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index f1044730ff..5cc239aea5 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -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