Subject: bug#24478: 25.1; Regression in 25.1: .tramp_history files are littered in non-$HOME working directories

From: Michael Albinus <[email-masked]>
Date: Sat, 15 Oct 2016 12:38:15 +0200

Michael Albinus <[email-masked]> writes:

Hi Ævar,

>> I.e. their /bin/sh is always bash, as opposed to say the more minimal
>> dash shell on Debian.
>
> Indeed. All the bugs I've quoted were related to bash.

Well, I've partly reverted the fix for bug#20446. This shall fix the
problem for you. See appended patch.

Glenn, you have reported bug#20446. I believe that I haven't
reintroduced your problem, but I would appreciate pretty much if you
could cross-check this. The point is NOT to set $HISTFILESIZE.

Best regards, Michael.

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs-25/lisp/net/tramp-sh.el.~4f406e9813e073b675bb45613bf1dd111eec2368~	2016-10-15 12:34:57.847998549 +0200
--- /home/albinus/src/emacs-25/lisp/net/tramp-sh.el	2016-10-15 12:28:04.562663524 +0200
***************
*** 67,85 ****
    :type 'string)
  
  ;;;###tramp-autoload
! (defcustom tramp-histfile-override ".tramp_history"
    "When invoking a shell, override the HISTFILE with this value.
  When setting to a string, it redirects the shell history to that
  file.  Be careful when setting to \"/dev/null\"; this might
  result in undesired results when using \"bash\" as shell.
  
  The value t, the default value, unsets any setting of HISTFILE,
! and sets both HISTFILESIZE and HISTSIZE to 0.  If you set this
! variable to nil, however, the *override* is disabled, so the
! history will go to the default storage location,
! e.g. \"$HOME/.sh_history\"."
    :group 'tramp
!   :version "25.1"
    :type '(choice (const :tag "Do not override HISTFILE" nil)
                   (const :tag "Unset HISTFILE" t)
                   (string :tag "Redirect to a file")))
--- 67,84 ----
    :type 'string)
  
  ;;;###tramp-autoload
! (defcustom tramp-histfile-override t
    "When invoking a shell, override the HISTFILE with this value.
  When setting to a string, it redirects the shell history to that
  file.  Be careful when setting to \"/dev/null\"; this might
  result in undesired results when using \"bash\" as shell.
  
  The value t, the default value, unsets any setting of HISTFILE,
! and sets HISTSIZE to 0.  If you set this variable to nil,
! however, the *override* is disabled, so the history will go to
! the default storage location, e.g. \"$HOME/.sh_history\"."
    :group 'tramp
!   :version "25.2"
    :type '(choice (const :tag "Do not override HISTFILE" nil)
                   (const :tag "Unset HISTFILE" t)
                   (string :tag "Redirect to a file")))
***************
*** 4113,4119 ****
  		(format "HISTFILE=%s"
  			(tramp-shell-quote-argument tramp-histfile-override))
  	      (if tramp-histfile-override
! 		  "HISTFILE='' HISTFILESIZE=0 HISTSIZE=0"
  		""))
  	    (tramp-shell-quote-argument tramp-end-of-output)
  	    shell (or extra-args ""))
--- 4112,4118 ----
  		(format "HISTFILE=%s"
  			(tramp-shell-quote-argument tramp-histfile-override))
  	      (if tramp-histfile-override
! 		  "HISTFILE='' HISTSIZE=0"
  		""))
  	    (tramp-shell-quote-argument tramp-end-of-output)
  	    shell (or extra-args ""))
***************
*** 4885,4891 ****
  		(if tramp-histfile-override
  		    (progn
  		      (setenv "HISTFILE")
- 		      (setenv "HISTFILESIZE" "0")
  		      (setenv "HISTSIZE" "0"))))
  	      (setenv "PROMPT_COMMAND")
  	      (setenv "PS1" tramp-initial-end-of-output)
--- 4884,4889 ----
--8<---------------cut here---------------end--------------->8---