From 6f8372ded12d52b389527d33232eba7951096d18 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Mon, 2 Feb 2015 12:38:36 +0100 Subject: [PATCH] Tramp: Support unsetting HISTFILE. Fixes: debbugs:19731 * lisp/net/tramp-sh.el (tramp-histfile-override): Add another choice 'unset. (tramp-open-shell, tramp-maybe-open-connection): Support it. --- lisp/ChangeLog | 6 ++++++ lisp/net/tramp-sh.el | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 846da3b0dee..fe0a3dba1a0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2015-02-02 Michael Albinus + + * net/tramp-sh.el (tramp-histfile-override): Add another choice 'unset. + (tramp-open-shell, tramp-maybe-open-connection): Support it. + (Bug#19731) + 2015-02-02 Thierry Volpiatto * emacs-lisp/package.el (package-delete): Remove package from diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 80a256c8d3b..9a5be77e66d 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -71,12 +71,15 @@ By default, the HISTFILE is set to the \"/dev/null\" value, which is special on Unix systems and indicates the shell history should not be logged (this avoids clutter due to Tramp commands). +The symbol `unset' removes any setting of HISTFILE. + 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" 'unset) (const :tag "Empty the history (/dev/null)" "/dev/null") (string :tag "Redirect to a file"))) @@ -3902,9 +3905,13 @@ 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=''%s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s" + "exec env ENV='' %s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s" (if tramp-histfile-override - (concat " HISTFILE=" tramp-histfile-override) + (concat + "HISTFILE=" + (if (eq tramp-histfile-override 'unset) + "" + (tramp-shell-quote-argument tramp-histfile-override)))) "") (tramp-shell-quote-argument tramp-end-of-output) shell (or extra-args "")) @@ -4628,7 +4635,9 @@ connection if a previous connection has died for some reason." (setenv "TERM" tramp-terminal-type) (setenv "LC_ALL" "en_US.utf8") (when tramp-histfile-override - (setenv "HISTFILE" tramp-histfile-override)) + (setenv "HISTFILE" + (and (not (eq tramp-histfile-override 'unset)) + tramp-histfile-override))) (setenv "PROMPT_COMMAND") (setenv "PS1" tramp-initial-end-of-output) (let* ((target-alist (tramp-compute-multi-hops vec)) -- 2.39.2