aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2013-03-01 22:12:26 +0100
committerMichael Albinus2013-03-01 22:12:26 +0100
commit7d11fc276327b0d2bd5045a03a1ca7f7f437e393 (patch)
tree36bc6703c279383be407c91f8a33e18835230c2b
parentb5a5723d4e4bcc88d5b67a0edc59eb37e364296c (diff)
downloademacs-7d11fc276327b0d2bd5045a03a1ca7f7f437e393.tar.gz
emacs-7d11fc276327b0d2bd5045a03a1ca7f7f437e393.zip
* net/tramp-adb.el (tramp-adb-prompt): Extend regexp.
(tramp-adb-handle-process-file): Remove superfluous setting. (tramp-adb-command-exit-status): Handle case that COMMAND is nil. (tramp-adb-barf-unless-okay): Use `tramp-adb-command-exit-status'. (tramp-adb-maybe-open-connection): Apply "su" if user is defined.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/net/tramp-adb.el53
2 files changed, 36 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 604435bfc61..8b6ffeed01d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12013-03-01 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp-adb.el (tramp-adb-prompt): Extend regexp.
4 (tramp-adb-handle-process-file): Remove superfluous setting.
5 (tramp-adb-command-exit-status): Handle case that COMMAND is nil.
6 (tramp-adb-barf-unless-okay): Use `tramp-adb-command-exit-status'.
7 (tramp-adb-maybe-open-connection): Apply "su" if user is defined.
8
12013-03-01 Stefan Monnier <monnier@iro.umontreal.ca> 92013-03-01 Stefan Monnier <monnier@iro.umontreal.ca>
2 10
3 * textmodes/ispell.el: Fix nitpicks and byte-compiler warnings. 11 * textmodes/ispell.el: Fix nitpicks and byte-compiler warnings.
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 766dcdbbe6a..910356fbb6c 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -49,7 +49,7 @@
49 "*When this method name is used, forward all calls to Android Debug Bridge.") 49 "*When this method name is used, forward all calls to Android Debug Bridge.")
50 50
51(defcustom tramp-adb-prompt 51(defcustom tramp-adb-prompt
52 "^\\(?:[[:alnum:]]*@[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]" 52 "^\\(?:[[:digit:]]*|?\\)?\\(?:[[:alnum:]]*@[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]"
53 "Regexp used as prompt in almquist shell." 53 "Regexp used as prompt in almquist shell."
54 :type 'string 54 :type 'string
55 :version "24.4" 55 :version "24.4"
@@ -775,13 +775,11 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
775 ;; directory. 775 ;; directory.
776 (condition-case nil 776 (condition-case nil
777 (progn 777 (progn
778 (setq ret 0 778 (setq ret 0)
779 ret 779 (tramp-adb-barf-unless-okay
780 (tramp-adb-barf-unless-okay 780 v (format "(cd %s; %s)"
781 v (format "(cd %s; %s)" 781 (tramp-shell-quote-argument localname) command)
782 (tramp-shell-quote-argument localname) 782 "")
783 command)
784 ""))
785 ;; We should show the output anyway. 783 ;; We should show the output anyway.
786 (when outbuf 784 (when outbuf
787 (with-current-buffer outbuf 785 (with-current-buffer outbuf
@@ -1011,34 +1009,31 @@ This happens for Android >= 4.0."
1011 (while (re-search-forward "\r+$" nil t) 1009 (while (re-search-forward "\r+$" nil t)
1012 (replace-match "" nil nil))))) 1010 (replace-match "" nil nil)))))
1013 1011
1014(defun tramp-adb-barf-unless-okay (vec command fmt &rest args)
1015 "Run COMMAND, check exit status, throw error if exit status not okay.
1016FMT and ARGS are passed to `error'."
1017 (tramp-adb-send-command vec (format "%s; echo tramp_exit_status $?" command))
1018 (with-current-buffer (tramp-get-connection-buffer vec)
1019 (goto-char (point-max))
1020 (unless (re-search-backward "tramp_exit_status [0-9]+" nil t)
1021 (tramp-error
1022 vec 'file-error "Couldn't find exit status of `%s'" command))
1023 (skip-chars-forward "^ ")
1024 (unless (zerop (read (current-buffer)))
1025 (apply 'tramp-error vec 'file-error fmt args))
1026 (let (buffer-read-only)
1027 (delete-region (match-beginning 0) (point-max)))))
1028
1029(defun tramp-adb-command-exit-status 1012(defun tramp-adb-command-exit-status
1030 (vec command) 1013 (vec command)
1031 "Run COMMAND and return its exit status. 1014 "Run COMMAND and return its exit status.
1032Sends `echo $?' along with the COMMAND for checking the exit status. If 1015Sends `echo $?' along with the COMMAND for checking the exit status. If
1033COMMAND is nil, just sends `echo $?'. Returns the exit status found." 1016COMMAND is nil, just sends `echo $?'. Returns the exit status found."
1034 (tramp-adb-send-command vec (format "%s; echo tramp_exit_status $?" command)) 1017 (tramp-adb-send-command
1018 vec (if command
1019 (format "%s; echo tramp_exit_status $?" command)
1020 "echo tramp_exit_status $?"))
1035 (with-current-buffer (tramp-get-connection-buffer vec) 1021 (with-current-buffer (tramp-get-connection-buffer vec)
1036 (goto-char (point-max)) 1022 (goto-char (point-max))
1037 (unless (re-search-backward "tramp_exit_status [0-9]+" nil t) 1023 (unless (re-search-backward "tramp_exit_status [0-9]+" nil t)
1038 (tramp-error 1024 (tramp-error
1039 vec 'file-error "Couldn't find exit status of `%s'" command)) 1025 vec 'file-error "Couldn't find exit status of `%s'" command))
1040 (skip-chars-forward "^ ") 1026 (skip-chars-forward "^ ")
1041 (read (current-buffer)))) 1027 (prog1
1028 (read (current-buffer))
1029 (let (buffer-read-only)
1030 (delete-region (match-beginning 0) (point-max))))))
1031
1032(defun tramp-adb-barf-unless-okay (vec command fmt &rest args)
1033 "Run COMMAND, check exit status, throw error if exit status not okay.
1034FMT and ARGS are passed to `error'."
1035 (unless (zerop (tramp-adb-command-exit-status vec command))
1036 (apply 'tramp-error vec 'file-error fmt args)))
1042 1037
1043(defun tramp-adb-wait-for-output (proc &optional timeout) 1038(defun tramp-adb-wait-for-output (proc &optional timeout)
1044 "Wait for output from remote command." 1039 "Wait for output from remote command."
@@ -1077,6 +1072,7 @@ connection if a previous connection has died for some reason."
1077 (let* ((buf (tramp-get-connection-buffer vec)) 1072 (let* ((buf (tramp-get-connection-buffer vec))
1078 (p (get-buffer-process buf)) 1073 (p (get-buffer-process buf))
1079 (host (tramp-file-name-host vec)) 1074 (host (tramp-file-name-host vec))
1075 (user (tramp-file-name-user vec))
1080 (devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))) 1076 (devices (mapcar 'cadr (tramp-adb-parse-device-names nil))))
1081 (unless 1077 (unless
1082 (and p (processp p) (memq (process-status p) '(run open))) 1078 (and p (processp p) (memq (process-status p) '(run open)))
@@ -1132,6 +1128,13 @@ connection if a previous connection has died for some reason."
1132 old-getprop new-getprop) 1128 old-getprop new-getprop)
1133 (tramp-adb-maybe-open-connection vec))) 1129 (tramp-adb-maybe-open-connection vec)))
1134 1130
1131 ;; Change user if indicated.
1132 (when user
1133 (tramp-adb-send-command vec (format "su %s" user))
1134 (unless (zerop (tramp-adb-command-exit-status vec nil))
1135 (delete-process p)
1136 (tramp-error vec 'file-error "Cannot switch to user %s" user)))
1137
1135 ;; Set "remote-path" connection property. This is needed 1138 ;; Set "remote-path" connection property. This is needed
1136 ;; for eshell. 1139 ;; for eshell.
1137 (tramp-adb-send-command vec "echo \\\"$PATH\\\"") 1140 (tramp-adb-send-command vec "echo \\\"$PATH\\\"")