Function: tramp-adb-send-command

tramp-adb-send-command is a byte-compiled function defined in tramp-adb.el.gz.

Signature

(tramp-adb-send-command VEC COMMAND &optional NEVEROPEN NOOUTPUT)

Documentation

Send the COMMAND to connection VEC.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-adb.el.gz
;; Connection functions

(defun tramp-adb-send-command (vec command &optional neveropen nooutput)
  "Send the COMMAND to connection VEC."
  (if (string-match-p (tramp-compat-rx multibyte) command)
      ;; Multibyte codepoints with four bytes are not supported at
      ;; least by toybox.

      ;; <https://android.stackexchange.com/questions/226638/how-to-use-multibyte-file-names-in-adb-shell/232379#232379>
      ;; mksh uses UTF-8 internally, but is currently limited to the
      ;; BMP (basic multilingua plane), which means U+0000 to
      ;; U+FFFD. If you want to use SMP codepoints (U-00010000 to
      ;; U-0010FFFD) on the input line, you currently have to disable
      ;; the UTF-8 mode (sorry).
      (tramp-adb-execute-adb-command vec "shell" command)

    (unless neveropen (tramp-adb-maybe-open-connection vec))
    (tramp-message vec 6 "%s" command)
    (tramp-send-string vec command)
    (unless nooutput
      ;; FIXME: Race condition.
      (tramp-adb-wait-for-output (tramp-get-connection-process vec))
      (with-current-buffer (tramp-get-connection-buffer vec)
	(save-excursion
	  (goto-char (point-min))
	  ;; We can't use stty to disable echo of command.  stty is said
	  ;; to be added to toybox 0.7.6.  busybox shall have it, but this
	  ;; isn't used any longer for Android.
	  (delete-matching-lines (tramp-compat-rx bol (literal command) eol))
	  ;; 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.
	  (goto-char (point-min))
	  (while (re-search-forward (rx (+ "\r") eol) nil t)
	    (replace-match "" nil nil)))))))