Subject: bug#17295: 24.3; Add TRAMP fixes for history clobbering to pretest

From: Michael Albinus <[email-masked]>
Date: Wed, 23 Apr 2014 10:23:37 +0200

Vasilij Schneidermann <[email-masked]> writes:

Hi Vasilij,

> According to Michael Albinus recent TRAMP versions have a bugfix that
> prevents TRAMP from clobbering history files on both local and remote
> hosts.  It would be nice to incorporate them into the current Emacs
> pretest, simply because it's a relevant bug affecting people and another
> patch for a less common issue has already been applied.

This has been fixed in Tramp 2.2.10-pre, indeed. Could you, please,
check the following patch, which is a backport of this for the Emacs
24.4 pretest?

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs-24/lisp/net/tramp-sh.el.~117003~	2014-04-23 10:17:34.876086596 +0200
--- /home/albinus/src/emacs-24/lisp/net/tramp-sh.el	2014-04-23 10:17:34.996088675 +0200
***************
*** 425,431 ****

  ;;;###tramp-autoload
  (defcustom tramp-remote-process-environment
!   `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "TMOUT=0" "LC_CTYPE=''"
      ,(format "TERM=%s" tramp-terminal-type)
      "EMACS=t" ;; Deprecated.
      ,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version)
--- 425,431 ----

  ;;;###tramp-autoload
  (defcustom tramp-remote-process-environment
!   `("TMOUT=0" "LC_CTYPE=''"
      ,(format "TERM=%s" tramp-terminal-type)
      "EMACS=t" ;; Deprecated.
      ,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version)
***************
*** 440,445 ****
--- 440,446 ----
  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"
    :type '(repeat string))

  (defcustom tramp-sh-extra-args '(("/bash\\'" . "-norc -noprofile"))
***************
*** 3735,3752 ****
  	  (setq extra-args (cdr item))))
        (tramp-send-command
         vec (format
! 	    "exec env ENV='' PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s"
  	    (tramp-shell-quote-argument tramp-end-of-output)
  	    shell (or extra-args ""))
         t))
      (tramp-set-connection-property
!      (tramp-get-connection-process vec) "remote-shell" shell)
!     ;; Setting prompts.
!     (tramp-send-command
!      vec (format "PS1=%s" (tramp-shell-quote-argument tramp-end-of-output)) t)
!     (tramp-send-command vec "PS2=''" t)
!     (tramp-send-command vec "PS3=''" t)
!     (tramp-send-command vec "PROMPT_COMMAND=''" t)))

  (defun tramp-find-shell (vec)
    "Opens a shell on the remote host which groks tilde expansion."
--- 3736,3747 ----
  	  (setq extra-args (cdr item))))
        (tramp-send-command
         vec (format
! 	    "exec env ENV='' HISTFILE=/dev/null PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s"
  	    (tramp-shell-quote-argument tramp-end-of-output)
  	    shell (or extra-args ""))
         t))
      (tramp-set-connection-property
!      (tramp-get-connection-process vec) "remote-shell" shell)))

  (defun tramp-find-shell (vec)
    "Opens a shell on the remote host which groks tilde expansion."
***************
*** 4456,4461 ****
--- 4451,4457 ----
  		(delete-process p))
  	      (setenv "TERM" tramp-terminal-type)
  	      (setenv "LC_ALL" "en_US.utf8")
+ 	      (setenv "HISTFILE" "/dev/null")
  	      (setenv "PROMPT_COMMAND")
  	      (setenv "PS1" tramp-initial-end-of-output)
  	      (let* ((target-alist (tramp-compute-multi-hops vec))
--8<---------------cut here---------------end--------------->8---

Thanks, and best regards, Michael.