Subject: tramp recreates /dev/null as a regular file when history limit is hit

From: Attila Molnár <[email-masked]>
Date: Thu, 17 Mar 2016 15:24:04 +0100

Hi,

I am Attila Molnar, from a small start-up from Hungary

Well the subject pretty well describes the problem...

I tried to override the history file value with:

(package-initialize)
(require 'tramp)
(defvar tramp-histfile-override "~/.tramp_history" "Prevent tramp from
using /dev/null and recreating it as a regular file when history size is
reached.")

With no success. However, I found the problem in the source code and fixed
it:

@@ -3865,7 +3865,7 @@ file exists and nonzero exit status otherwise."
       ;; the prompt in /bin/bash, it must be discarded as well.
       (tramp-send-command
        vec (format
-    "exec env ENV='' HISTFILE=/dev/null PROMPT_COMMAND='' PS1=%s PS2=''
PS3='' %s %s"
+    "exec env ENV='' HISTFILE=~/.tramp_history PROMPT_COMMAND='' PS1=%s
PS2='' PS3='' %s %s"
     (tramp-shell-quote-argument tramp-end-of-output)
     shell (or extra-args ""))
        t))
@@ -4587,7 +4587,7 @@ connection if a previous connection has died for some
reason."
  (delete-process p))
       (setenv "TERM" tramp-terminal-type)
       (setenv "LC_ALL" "en_US.utf8")
-      (setenv "HISTFILE" "/dev/null")
+      (setenv "HISTFILE" "~/.tramp_history")
       (setenv "PROMPT_COMMAND")
       (setenv "PS1" tramp-initial-end-of-output)
       (let* ((target-alist (tramp-compute-multi-hops vec))

Data about my Emacs:

In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.7)
 of 2016-03-07 on attilaWorkStation
Windowing system distributor `The X.Org Foundation', version 11.0.11704000
System Description: NAME=Gentoo

Configured using:
 `configure --prefix=/usr --build=x86_64-pc-linux-gnu
 --host=x86_64-pc-linux-gnu --mandir=/usr/share/man
 --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
 --localstatedir=/var/lib --disable-dependency-tracking
 --disable-silent-rules --libdir=/usr/lib64 --program-suffix=-emacs-24
 --infodir=/usr/share/info/emacs-24 --localstatedir=/var
 --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
 --with-gameuser=:gamestat --without-compress-install
 --with-file-notification=inotify --enable-acl --with-dbus --with-gpm
 --with-hesiod --without-kerberos --without-kerberos5 --without-xml2
 --without-selinux --with-gnutls --without-wide-int --with-zlib
 --with-sound=alsa --with-x --without-ns --with-gconf --with-gsettings
 --without-toolkit-scroll-bars --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xpm --with-imagemagick --with-xft
 --without-libotf --without-m17n-flt --with-x-toolkit=gtk3
 GENTOO_PACKAGE=app-editors/emacs-24.5-r1 'CFLAGS=-march=core2 -O2
 -pipe' CPPFLAGS= 'LDFLAGS=-Wl,-O1 -Wl,--as-needed''

Important settings:
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  TeX-PDF-mode: t
  pyvenv-mode: t
  global-company-mode: t
  company-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  rainbow-delimiters-mode: t
  projectile-global-mode: t
  projectile-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  helm-mode: t
  helm-adaptive-mode: t
  diff-auto-refine-mode: t
  magit-auto-revert-mode: t
  auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  fic-ext-mode: t
  shell-dirtrack-mode: t
  show-paren-mode: t
  global-linum-mode: t
  linum-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Mark set
Type C-h i to view popup manual, ? to describe an argument or action.
(No files need saving)
Mark set
Type C-h i to view popup manual, ? to describe an argument or action.
(No files need saving)
Quit
delete-backward-char: Text is read-only
Mark saved where search started
Mark activated

Load-path shadows:
/home/attila/.emacs.d/elpa/helm-20160221.2157/helm-multi-match hides
/home/attila/.emacs.d/elpa/helm-core-20160221.2350/helm-multi-match
/home/attila/.emacs.d/elpa/auctex-11.89.1/latex hides
/usr/share/emacs/site-lisp/auctex/latex
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex hides
/usr/share/emacs/site-lisp/auctex/tex
/home/attila/.emacs.d/elpa/auctex-11.89.1/font-latex hides
/usr/share/emacs/site-lisp/auctex/font-latex
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex-bar hides
/usr/share/emacs/site-lisp/auctex/tex-bar
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex-font hides
/usr/share/emacs/site-lisp/auctex/tex-font
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex-fold hides
/usr/share/emacs/site-lisp/auctex/tex-fold
/home/attila/.emacs.d/elpa/auctex-11.89.1/context-en hides
/usr/share/emacs/site-lisp/auctex/context-en
/home/attila/.emacs.d/elpa/auctex-11.89.1/bib-cite hides
/usr/share/emacs/site-lisp/auctex/bib-cite
/home/attila/.emacs.d/elpa/auctex-11.89.1/context hides
/usr/share/emacs/site-lisp/auctex/context
/home/attila/.emacs.d/elpa/auctex-11.89.1/texmathp hides
/usr/share/emacs/site-lisp/auctex/texmathp
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex-site hides
/usr/share/emacs/site-lisp/auctex/tex-site
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex-buf hides
/usr/share/emacs/site-lisp/auctex/tex-buf
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex-info hides
/usr/share/emacs/site-lisp/auctex/tex-info
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex-mik hides
/usr/share/emacs/site-lisp/auctex/tex-mik
/home/attila/.emacs.d/elpa/auctex-11.89.1/multi-prompt hides
/usr/share/emacs/site-lisp/auctex/multi-prompt
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex-jp hides
/usr/share/emacs/site-lisp/auctex/tex-jp
/home/attila/.emacs.d/elpa/auctex-11.89.1/context-nl hides
/usr/share/emacs/site-lisp/auctex/context-nl
/home/attila/.emacs.d/elpa/auctex-11.89.1/plain-tex hides
/usr/share/emacs/site-lisp/auctex/plain-tex
/home/attila/.emacs.d/elpa/auctex-11.89.1/auctex hides
/usr/share/emacs/site-lisp/auctex/auctex
/home/attila/.emacs.d/elpa/auctex-11.89.1/tex-style hides
/usr/share/emacs/site-lisp/auctex/tex-style
/home/attila/.emacs.d/elpa/auctex-11.89.1/toolbar-x hides
/usr/share/emacs/site-lisp/auctex/toolbar-x
/home/attila/.emacs.d/elpa/xcscope-20160201.1926/xcscope hides
/usr/share/emacs/site-lisp/cscope/xcscope

Features:
(shadow sort mail-extr emacsbug sendmail helm-command helm-elisp
helm-eval edebug tramp-cmds tramp-cache sh-script smie executable
misearch multi-isearch mule-util image-file winner org-element org-rmail
org-mhe org-irc org-info org-gnus org-docview doc-view jka-compr
image-mode org-bibtex bibtex org-bbdb org-w3m org org-macro org-footnote
org-pcomplete org-list org-faces org-entities noutline outline
org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-src ob-keys ob-comint ob-core ob-eval org-compat org-macs
org-loaddefs cal-menu calendar cal-loaddefs company-oddmuse
company-keywords company-etags company-gtags company-dabbrev-code
company-dabbrev company-files company-capf company-cmake company-xcode
company-clang company-eclim company-template company-css company-nxml
company-bbdb company-c-headers auto-complete-auctex latex tex-style tex
dbus tex-mik helm-css-scss jquery-doc jquery-doc-data company-tern
dash-functional tern url-http tls url-auth url-gw js2-refactor
js2r-paredit js2r-conveniences js2r-conditionals js2r-wrapping
js2r-functions js2r-vars multiple-cursors-core rect js2r-iife
js2r-formatting js2r-helpers s ucs-normalize js2-mode js2-old-indent
sgml-mode js impatient-mode htmlize simple-httpd web-mode disp-table
python-django tree-widget sql view hippie-exp highlight-indentation
flymake eldoc elpy pyvenv elpy-refactor python json ido files-x etags
cus-edit cus-start cus-load wid-edit cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs helm-gtags pulse
which-func imenu helm-cscope xcscope company pcase undo-tree diff
flyspell ispell flycheck find-func subr-x seq rainbow-delimiters
auto-complete popup helm-ack helm-projectile projectile grep ibuf-ext
ibuffer helm-ls-git vc-git vc vc-dispatcher helm-c-yasnippet yasnippet
cl helm-mode helm-files rx image-dired dired-x dired-aux ffap thingatpt
helm-buffers helm-elscreen helm-tags helm-bookmark helm-info bookmark pp
helm-locate helm-grep helm-regexp helm-plugin helm-external helm-net
browse-url xml url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util url-parse url-vars mailcap
helm-utils compile helm-help helm-types helm-adaptive helm-config
helm-easymenu helm helm-source helm-multi-match helm-lib avy magit-blame
magit-stash magit-bisect magit-remote magit-commit magit-sequence magit
magit-apply dired magit-wip magit-log magit-diff smerge-mode diff-mode
magit-core magit-autorevert autorevert filenotify magit-process
magit-popup magit-mode help-mode magit-git crm magit-section magit-utils
git-commit log-edit easy-mmode message idna rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log with-editor
cl-macs gv async-bytecomp async tramp-sh dash fic-ext-mode goto-chg
pager server tramp tramp-compat auth-source eieio byte-opt bytecomp
byte-compile cl-extra cconv gnus-util mm-util mail-prsvr password-cache
tramp-loaddefs trampver shell pcomplete comint ansi-color ring
format-spec advice help-fns eieio-core info easymenu package epg-config
edmacro kmacro cl-loaddefs cl-lib paren linum monokai-theme site-gentoo
tex-site auto-loads time-date tooltip electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)

Memory information:
((conses 16 715083 71192)
 (symbols 48 63184 0)
 (miscs 40 3518 1875)
 (strings 32 172729 20680)
 (string-bytes 1 5341385)
 (vectors 16 91713)
 (vector-slots 8 2106227 45875)
 (floats 8 1289 1056)
 (intervals 56 3099 576)
 (buffers 960 33)
 (heap 1024 84945 33520))