bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#30595: [PATCH] Handle command line wrapping in Tramp adb.


From: Mathieu Othacehe
Subject: bug#30595: [PATCH] Handle command line wrapping in Tramp adb.
Date: Sat, 24 Feb 2018 19:07:09 +0100

The command sent to an adb shell input might be wrapped around
terminal column count by the kernel. Remove CR and LF introduced when
it happends.

* lisp/net/tramp-adb.el (tramp-adb-send-command): Remove W32 trailing
  CR but also CR/LF introduced by command line wrapping.
---
 lisp/net/tramp-adb.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index be269aca51..532569414b 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -1178,14 +1178,17 @@ tramp-adb-send-command
   (with-current-buffer (tramp-get-connection-buffer vec)
     (save-excursion
       (goto-char (point-min))
-      ;; We can't use stty to disable echo of command.
-      (delete-matching-lines (regexp-quote command))
       ;; When the local machine is W32, there are still trailing ^M.
       ;; There must be a better solution by setting the correct coding
       ;; system, but this requires changes in core Tramp.
+      ;;
+      ;; Also remove CR and LF introduced by kernel when input command
+      ;; is longer than terminal column count.
+      (while (re-search-forward "\r+\n*" nil t)
+       (replace-match "" nil nil))
       (goto-char (point-min))
-      (while (re-search-forward "\r+$" nil t)
-       (replace-match "" nil nil)))))
+      ;; We can't use stty to disable echo of command.
+      (delete-matching-lines (regexp-quote command)))))
 
 (defun tramp-adb-send-command-and-check (vec command)
   "Run COMMAND and check its exit status.
-- 
2.16.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]