From 40d41dd4971a880b30b505e6f0da797048983954 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 14 Nov 2017 11:38:30 +0100 Subject: [PATCH] Fix Bug#28139 * tramp-sh.el: Set TERM and INSIDE_EMACS environment earlier. (tramp-remote-process-environment): Remove TERM and INSIDE_EMACS. (tramp-remote-process-environment): Document their special handling. (tramp-open-shell): Set TERM and INSIDE_EMACS prior to starting the initial remote shell, so that it is also aware of the environment in which it is operating. (Bug#28139) --- lisp/net/tramp-sh.el | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 52a6b8fac0b..acb5a12ba2a 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -533,9 +533,7 @@ the list by the special value `tramp-own-remote-path'." ;;;###tramp-autoload (defcustom tramp-remote-process-environment - `("ENV=''" "TMOUT=0" "LC_CTYPE=''" - ,(format "TERM=%s" tramp-terminal-type) - ,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version) + '("ENV=''" "TMOUT=0" "LC_CTYPE=''" "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat" "autocorrect=" "correct=") "List of environment variables to be set on the remote host. @@ -544,8 +542,15 @@ Each element should be a string of the form ENVVARNAME=VALUE. An entry ENVVARNAME= disables the corresponding environment variable, 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'." +Special handling is applied to some environment variables, +which should not be set here: + +The PATH environment variable should be set via `tramp-remote-path'. + +The TERM environment variable should be set via `tramp-terminal-type'. + +The INSIDE_EMACS environment variable will automatically be set +based on the TRAMP and Emacs versions, and should not be set here." :group 'tramp :version "26.1" :type '(repeat string) @@ -3948,9 +3953,17 @@ file exists and nonzero exit status otherwise." ;; file clobbering $PS1. $PROMPT_COMMAND is another way to set ;; the prompt in /bin/bash, it must be discarded as well. ;; $HISTFILE is set according to `tramp-histfile-override'. + ;; $TERM and $INSIDE_EMACS set here to ensure they have the + ;; correct values when the shell starts, not just processes + ;; run within the shell. (Which processes include our + ;; initial probes to ensure the remote shell is usable.) (tramp-send-command vec (format - "exec env ENV=%s %s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s" + (concat + "exec env TERM='%s' INSIDE_EMACS='%s,tramp:%s' " + "ENV=%s %s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s") + tramp-terminal-type + emacs-version tramp-version ; INSIDE_EMACS (or (getenv-internal "ENV" tramp-remote-process-environment) "") (if (stringp tramp-histfile-override) (format "HISTFILE=%s" -- 2.39.2