$OpenBSD: patch-lisp_net_tramp-sh_el,v 1.1 2014/12/12 12:43:34 jca Exp $

- fix a hang in tramp-mode.

commit b14b7f431fe9cfcdcb23eecf105992d1c276dc69
Author: Wolfgang Jenkner <wjenkner@inode.at>
Date:   Sat Nov 1 15:08:00 2014 +0100

    * net/tramp-sh.el (tramp-send-command): Fix the case where the
    remote-echo connection property is non-nil.

    Fixes: debbugs:18858

--- lisp/net/tramp-sh.el.orig	Mon Jun 23 02:47:02 2014
+++ lisp/net/tramp-sh.el	Tue Dec  2 19:39:16 2014
@@ -4657,6 +4657,17 @@ function waits for output unless NOOUTPUT is set."
     (when (tramp-get-connection-property p "remote-echo" nil)
       ;; We mark the command string that it can be erased in the output buffer.
       (tramp-set-connection-property p "check-remote-echo" t)
+      ;; If we put `tramp-echo-mark' after a trailing newline (which
+      ;; is assumed to be unquoted) `tramp-send-string' doesn't see
+      ;; that newline and adds `tramp-rsh-end-of-line' right after
+      ;; `tramp-echo-mark', so the remote shell sees two consecutive
+      ;; trailing line endings and sends two prompts after executing
+      ;; the command, which confuses `tramp-wait-for-output'.
+      (when (and (not (string= command ""))
+		 (string-equal (substring command -1) "\n"))
+	(setq command (substring command 0 -1)))
+      ;; No need to restore a trailing newline here since `tramp-send-string'
+      ;; makes sure that the string ends in `tramp-rsh-end-of-line', anyway.
       (setq command (format "%s%s%s" tramp-echo-mark command tramp-echo-mark)))
     ;; Send the command.
     (tramp-message vec 6 "%s" command)
