Function: tramp-adb-send-command-and-check

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

Signature

(tramp-adb-send-command-and-check VEC COMMAND &optional EXIT-STATUS COMMAND-AUGMENTED-P)

Documentation

Run COMMAND and check its exit status.

Sends echo $? along with the COMMAND for checking the exit status. If COMMAND is nil, just sends echo $?. Returns nil if the exit status is not equal 0, and t otherwise.

If COMMAND-AUGMENTED-P, COMMAND is already configured to print exit status upon completion and need not be modified.

Optional argument EXIT-STATUS, if non-nil, triggers the return of the exit status.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-adb.el.gz
(defun tramp-adb-send-command-and-check
    (vec command &optional exit-status command-augmented-p)
  "Run COMMAND and check its exit status.
Sends `echo $?' along with the COMMAND for checking the exit
status.  If COMMAND is nil, just sends `echo $?'.  Returns nil if
the exit status is not equal 0, and t otherwise.

If COMMAND-AUGMENTED-P, COMMAND is already configured to print exit
status upon completion and need not be modified.

Optional argument EXIT-STATUS, if non-nil, triggers the return of
the exit status."
  (tramp-adb-send-command
   vec (if command
	   (if command-augmented-p
               command
             (format "%s; echo tramp_exit_status $?" command))
	 "echo tramp_exit_status $?"))
  (with-current-buffer (tramp-get-connection-buffer vec)
    (unless (tramp-search-regexp (rx "tramp_exit_status " (+ digit)))
      (tramp-error
       vec 'file-error "Couldn't find exit status of `%s'" command))
    (skip-chars-forward "^ ")
    (prog1
	(if exit-status
	    (read (current-buffer))
	  (zerop (read (current-buffer))))
      (let ((inhibit-read-only t))
	(delete-region (match-beginning 0) (point-max))))))