changeset 96941:940a290a5646

* net/tramp.el (tramp-methods): Add "-q" for "scp", "scp1", "scp2", "ssh", "ssh1", "ssh2", "scpc", "scpx", "sshx". (tramp-temp-buffer-name): New defconst. (tramp-handle-start-file-process): Use it. Apply "exec", for the command. No trailing prompt. (tramp-process-sentinel): Remove temporary buffer, if existing. Don't handle trailing prompt. (tramp-open-connection-setup-interactive-shell): Use `tramp-temp-buffer-name'.
author Michael Albinus <michael.albinus@gmx.de>
date Wed, 23 Jul 2008 19:17:05 +0000
parents 99669ed07fd2
children b66427dd3221
files lisp/net/tramp.el
diffstat 1 files changed, 32 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/net/tramp.el	Wed Jul 23 17:26:48 2008 +0000
+++ b/lisp/net/tramp.el	Wed Jul 23 19:17:05 2008 +0000
@@ -282,7 +282,7 @@
 	     (tramp-copy-keep-date       t)
 	     (tramp-password-end-of-line nil))
     ("scp"   (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
 					  ("-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -295,7 +295,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scp1"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
 					  ("-1" "-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -309,7 +309,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scp2"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
 					  ("-2" "-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -371,7 +371,7 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("ssh"   (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
 					  ("-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -384,7 +384,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("ssh1"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
 					  ("-1" "-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -397,7 +397,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("ssh2"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
 					  ("-2" "-e" "none")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -459,7 +459,7 @@
 	     (tramp-copy-keep-date       nil)
 	     (tramp-password-end-of-line nil))
     ("scpc"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
 					  ("-o" "ControlPath=%t.%%r@%%h:%%p")
 					  ("-o" "ControlMaster=yes")
 					  ("-e" "none")))
@@ -476,7 +476,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("scpx"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
 					  ("-e" "none" "-t" "-t" "/bin/sh")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         "scp")
@@ -489,7 +489,7 @@
 					  ("-o" "StrictHostKeyChecking=no")))
 	     (tramp-default-port         22))
     ("sshx"  (tramp-login-program        "ssh")
-             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p")
+             (tramp-login-args           (("%h") ("-l" "%u") ("-p" "%p") ("-q")
 					  ("-e" "none" "-t" "-t" "/bin/sh")))
 	     (tramp-remote-sh            "/bin/sh")
 	     (tramp-copy-program         nil)
@@ -1076,6 +1076,10 @@
   :group 'tramp
   :type 'string)
 
+(defconst tramp-temp-buffer-name " *tramp temp*"
+  "Buffer name for a temporary buffer.
+It shall be used in combination with `generate-new-buffer-name'.")
+
 (defcustom tramp-sh-extra-args '(("/bash\\'" . "-norc -noprofile"))
   "*Alist specifying extra arguments to pass to the remote shell.
 Entries are (REGEXP . ARGS) where REGEXP is a regular expression
@@ -3674,12 +3678,13 @@
   (with-parsed-tramp-file-name default-directory nil
     (unwind-protect
 	(progn
+	  (unless buffer
+	    ;; BUFFER can be nil.  We use a temporary buffer, which is
+	    ;; killed in `tramp-process-sentinel'.
+	    (setq buffer (generate-new-buffer tramp-temp-buffer-name)))
 	  ;; Set the new process properties.
 	  (tramp-set-connection-property v "process-name" name)
-	  (tramp-set-connection-property
-	   v "process-buffer"
-	   ;; BUFFER can be nil.
-	   (get-buffer-create (or buffer (current-buffer))))
+	  (tramp-set-connection-property v "process-buffer" buffer)
 	  ;; Activate narrowing in order to save BUFFER contents.
 	  ;; Clear also the modification time; otherwise we might be
 	  ;; interrupted by `verify-visited-file-modtime'.
@@ -3693,10 +3698,9 @@
 	  ;; Send the command.
 	  (tramp-send-command
 	   v
-	   (format "%s; echo %s; exit"
+	   (format "exec %s"
 		   (mapconcat 'tramp-shell-quote-argument
-			      (cons program args) " ")
-		   (tramp-shell-quote-argument tramp-end-of-output))
+			      (cons program args) " "))
 	   nil t) ; nooutput
 	  ;; Return process.
 	  (tramp-get-connection-process v))
@@ -5747,18 +5751,11 @@
   "Process sentinel for Tramp processes."
   (when (memq (process-status proc) '(stop exit signal))
     (tramp-flush-connection-property proc)
-    ;; The "Connection closed" and "exit" messages disturb the output
-    ;; for asynchronous processes.  That's why we have echoed the
-    ;; Tramp prompt at the end.  Trailing messages can be removed.
+    ;; Asynchronous processes might have a temporary buffer.  Kill it.
     (let ((buf (process-buffer proc)))
-      (when (buffer-live-p buf)
-        (with-current-buffer buf
-          (goto-char (point-max))
-          (re-search-backward
-           (mapconcat 'identity (split-string tramp-end-of-output "\n")
-                      "\r?\n")
-           (line-beginning-position -8) t)
-          (delete-region (point) (point-max)))))))
+      (when (and (buffer-live-p buf)
+		 (string-match tramp-temp-buffer-name (buffer-name buf)))
+	(kill-buffer buf)))))
 
 (defun tramp-open-connection-setup-interactive-shell (proc vec)
   "Set up an interactive shell.
@@ -5857,7 +5854,8 @@
     (when (and (stringp old-uname) (not (string-equal old-uname new-uname)))
       (with-current-buffer (tramp-get-debug-buffer vec)
 	;; Keep the debug buffer
-	(rename-buffer " *temp*" 'unique)
+	(rename-buffer
+	 (generate-new-buffer-name tramp-temp-buffer-name) 'unique)
 	(funcall (symbol-function 'tramp-cleanup-connection) vec)
 	(if (= (point-min) (point-max))
 	    (kill-buffer nil)
@@ -6351,7 +6349,7 @@
 		      l-host (match-string 1 l-host)))
 
 	      ;; Set variables for computing the prompt for reading
-	      ;; password.  They can also be derived from a gatewy.
+	      ;; password.  They can also be derived from a gateway.
 	      (setq tramp-current-method (or g-method l-method)
 		    tramp-current-user   (or g-user   l-user)
 		    tramp-current-host   (or g-host   l-host))
@@ -7533,6 +7531,11 @@
 ;;   detects that the process "has died". (David Reitter)
 ;; * How can I interrupt the remote process with a signal
 ;;   (interrupt-process seems not to work)? (Markus Triska)
+;; * Avoid the local shell entirely for starting remote processes.  If
+;;   so, I think even a signal, when delivered directly to the local
+;;   SSH instance, would correctly be propagated to the remote process
+;;   automatically; possibly SSH would have to be started with
+;;   "-t". (Markus Triska)
 
 ;; Functions for file-name-handler-alist:
 ;; diff-latest-backup-file -- in diff.el