]> code.delx.au - gnu-emacs/blobdiff - lisp/net/tramp-sh.el
Tramp: Disable paging with PAGER=cat.
[gnu-emacs] / lisp / net / tramp-sh.el
index 6fc2effbe0f6d59d8a4c0c1ac5885ff4572ff65c..f3fdb63bb9ee3f66c62187b72ce708d15c90646a 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tramp-sh.el --- Tramp access functions for (s)sh-like connections
 
-;; Copyright (C) 1998-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2015 Free Software Foundation, Inc.
 
 ;; (copyright statements below in code to be updated with the above notice)
 
@@ -65,19 +65,21 @@ files conditionalize this setup based on the TERM environment variable."
   :type 'string)
 
 ;;;###tramp-autoload
-(defcustom tramp-histfile-override "/dev/null"
+(defcustom tramp-histfile-override t
   "When invoking a shell, override the HISTFILE with this value.
-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).
-
-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\"."
+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 "Empty the history (/dev/null)" "/dev/null")
+                 (const :tag "Unset HISTFILE" t)
                  (string :tag "Redirect to a file")))
 
 ;;;###tramp-autoload
@@ -473,7 +475,7 @@ as given in your `~/.profile'."
     ,(format "TERM=%s" tramp-terminal-type)
     "EMACS=t" ;; Deprecated.
     ,(format "INSIDE_EMACS='%s,tramp:%s'" emacs-version tramp-version)
-    "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=\"\""
+    "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" "PAGER=cat"
     "autocorrect=" "correct=")
   "List of environment variables to be set on the remote host.
 
@@ -736,7 +738,7 @@ on the remote host.")
 (defconst tramp-perl-encode
   "%s -e '
 # This script contributed by Juanma Barranquero <lektu@terra.es>.
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 Free Software Foundation, Inc.
 use strict;
 
 my %%trans = do {
@@ -774,7 +776,7 @@ This string is passed to `format', so percent characters need to be doubled.")
 (defconst tramp-perl-decode
   "%s -e '
 # This script contributed by Juanma Barranquero <lektu@terra.es>.
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 Free Software Foundation, Inc.
 use strict;
 
 my %%trans = do {
@@ -3794,7 +3796,7 @@ This function expects to be in the right *tramp* buffer."
        (tramp-send-command
         vec
         (format (concat "while read d; "
-                        "do if test -x $d/%s -a -f $d/%s; "
+                        "do if test -x $d/%s && test -f $d/%s; "
                         "then echo tramp_executable $d/%s; "
                         "break; fi; done <<'%s'\n"
                         "%s\n%s")
@@ -3900,12 +3902,16 @@ file exists and nonzero exit status otherwise."
       ;; when called as sh) on startup; this way, we avoid the startup
       ;; 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'.
       (tramp-send-command
        vec (format
-           "exec env ENV=''%s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s"
-            (if tramp-histfile-override
-                (concat " HISTFILE=" tramp-histfile-override)
-              "")
+           "exec env ENV='' %s PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s"
+           (if (stringp tramp-histfile-override)
+               (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 ""))
        t))
@@ -4627,8 +4633,13 @@ connection if a previous connection has died for some reason."
                (delete-process p))
              (setenv "TERM" tramp-terminal-type)
              (setenv "LC_ALL" "en_US.utf8")
-             (when tramp-histfile-override
-                (setenv "HISTFILE" tramp-histfile-override))
+             (if (stringp tramp-histfile-override)
+                 (setenv "HISTFILE" tramp-histfile-override)
+               (if tramp-histfile-override
+                   (progn
+                     (setenv "HISTFILE")
+                     (setenv "HISTFILESIZE" "0")
+                     (setenv "HISTSIZE" "0"))))
              (setenv "PROMPT_COMMAND")
              (setenv "PS1" tramp-initial-end-of-output)
              (let* ((target-alist (tramp-compute-multi-hops vec))