emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r111909: * net/tramp-adb.el (tramp-ad


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111909: * net/tramp-adb.el (tramp-adb-prompt): Extend regexp.
Date: Fri, 01 Mar 2013 22:12:26 +0100
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111909
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Fri 2013-03-01 22:12:26 +0100
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/net/tramp-adb.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-03-01 17:46:57 +0000
+++ b/lisp/ChangeLog    2013-03-01 21:12:26 +0000
@@ -1,3 +1,11 @@
+2013-03-01  Michael Albinus  <address@hidden>
+
+       * 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.
+
 2013-03-01  Stefan Monnier  <address@hidden>
 
        * textmodes/ispell.el: Fix nitpicks and byte-compiler warnings.

=== modified file 'lisp/net/tramp-adb.el'
--- a/lisp/net/tramp-adb.el     2013-02-28 19:33:03 +0000
+++ b/lisp/net/tramp-adb.el     2013-03-01 21:12:26 +0000
@@ -49,7 +49,7 @@
   "*When this method name is used, forward all calls to Android Debug Bridge.")
 
 (defcustom tramp-adb-prompt
-  "^\\(?:[[:alnum:address@hidden:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]"
+  
"^\\(?:[[:digit:]]*|?\\)?\\(?:[[:alnum:address@hidden:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]"
   "Regexp used as prompt in almquist shell."
   :type 'string
   :version "24.4"
@@ -775,13 +775,11 @@
       ;; directory.
       (condition-case nil
          (progn
-           (setq ret 0
-                 ret
-                 (tramp-adb-barf-unless-okay
-                  v (format "(cd %s; %s)"
-                            (tramp-shell-quote-argument localname)
-                            command)
-                  ""))
+           (setq ret 0)
+           (tramp-adb-barf-unless-okay
+            v (format "(cd %s; %s)"
+                      (tramp-shell-quote-argument localname) command)
+            "")
            ;; We should show the output anyway.
            (when outbuf
              (with-current-buffer outbuf
@@ -1011,34 +1009,31 @@
       (while (re-search-forward "\r+$" nil t)
        (replace-match "" nil nil)))))
 
-(defun tramp-adb-barf-unless-okay (vec command fmt &rest args)
-  "Run COMMAND, check exit status, throw error if exit status not okay.
-FMT and ARGS are passed to `error'."
-  (tramp-adb-send-command vec (format "%s; echo tramp_exit_status $?" command))
-  (with-current-buffer (tramp-get-connection-buffer vec)
-    (goto-char (point-max))
-    (unless (re-search-backward "tramp_exit_status [0-9]+" nil t)
-      (tramp-error
-       vec 'file-error "Couldn't find exit status of `%s'" command))
-    (skip-chars-forward "^ ")
-    (unless (zerop (read (current-buffer)))
-      (apply 'tramp-error vec 'file-error fmt args))
-    (let (buffer-read-only)
-      (delete-region (match-beginning 0) (point-max)))))
-
 (defun tramp-adb-command-exit-status
   (vec command)
   "Run COMMAND and return its exit status.
 Sends `echo $?' along with the COMMAND for checking the exit status.  If
 COMMAND is nil, just sends `echo $?'.  Returns the exit status found."
-  (tramp-adb-send-command vec (format "%s; echo tramp_exit_status $?" command))
+  (tramp-adb-send-command
+   vec (if command
+          (format "%s; echo tramp_exit_status $?" command)
+        "echo tramp_exit_status $?"))
   (with-current-buffer (tramp-get-connection-buffer vec)
     (goto-char (point-max))
     (unless (re-search-backward "tramp_exit_status [0-9]+" nil t)
       (tramp-error
        vec 'file-error "Couldn't find exit status of `%s'" command))
     (skip-chars-forward "^ ")
-    (read (current-buffer))))
+    (prog1
+       (read (current-buffer))
+      (let (buffer-read-only)
+       (delete-region (match-beginning 0) (point-max))))))
+
+(defun tramp-adb-barf-unless-okay (vec command fmt &rest args)
+  "Run COMMAND, check exit status, throw error if exit status not okay.
+FMT and ARGS are passed to `error'."
+  (unless (zerop (tramp-adb-command-exit-status vec command))
+    (apply 'tramp-error vec 'file-error fmt args)))
 
 (defun tramp-adb-wait-for-output (proc &optional timeout)
   "Wait for output from remote command."
@@ -1077,6 +1072,7 @@
   (let* ((buf (tramp-get-connection-buffer vec))
         (p (get-buffer-process buf))
         (host (tramp-file-name-host vec))
+        (user (tramp-file-name-user vec))
         (devices (mapcar 'cadr (tramp-adb-parse-device-names nil))))
     (unless
        (and p (processp p) (memq (process-status p) '(run open)))
@@ -1132,6 +1128,13 @@
                 old-getprop new-getprop)
                (tramp-adb-maybe-open-connection vec)))
 
+           ;; Change user if indicated.
+           (when user
+             (tramp-adb-send-command vec (format "su %s" user))
+             (unless (zerop (tramp-adb-command-exit-status vec nil))
+               (delete-process p)
+               (tramp-error vec 'file-error "Cannot switch to user %s" user)))
+
            ;; Set "remote-path" connection property.  This is needed
            ;; for eshell.
            (tramp-adb-send-command vec "echo \\\"$PATH\\\"")


reply via email to

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