tramp-devel
[Top][All Lists]
Advanced

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

[PATCH 1/1] tramp-handle-process-file: merge three remote ops into one


From: Julian Scheid
Subject: [PATCH 1/1] tramp-handle-process-file: merge three remote ops into one
Date: Mon, 17 Aug 2009 10:12:15 +1200

---
 lisp/ChangeLog |    5 +++++
 lisp/tramp.el  |   20 +++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4e75aed..d7d31f3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2009-08-16  Julian Scheid  <address@hidden>
+
+       * tramp.el (tramp-handle-process-file): Merge three remote ops
+       into one.
+
 2009-08-16  Michael Albinus  <address@hidden>
 
        * tramp-cache.el (top): Autoload `tramp-time-less-p'.
diff --git a/lisp/tramp.el b/lisp/tramp.el
index c4019cb..8474afe 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -4160,18 +4160,26 @@ beginning of local filename are not substituted."
        (setq outbuf (current-buffer))))
       (when stderr (setq command (format "%s 2>%s" command stderr)))
 
-      ;; Goto working directory.
-      (tramp-send-command
-       v (format "cd %s" (tramp-shell-quote-argument localname)))
       ;; Send the command.  It might not return in time, so we protect it.
       (condition-case nil
          (unwind-protect
-             (tramp-send-command v command)
+             (tramp-send-command
+               v (format
+                  "\\cd %s; %s; \\echo tramp_exit_status $?"
+                  (tramp-shell-quote-argument localname) command))
            ;; We should show the output anyway.
            (when outbuf
              (let ((output-string
                     (with-current-buffer (tramp-get-connection-buffer v)
-                      (buffer-substring (point-min) (point-max)))))
+                       (if (re-search-backward
+                            "tramp_exit_status \\([0-9]+\\)" nil t)
+                           (progn
+                             (setq ret (string-to-int (match-string 1)))
+                             (buffer-substring (point-min) (match-beginning 
0)))
+                         (tramp-error
+                          v 'file-error
+                          "tramp-handle-process-file: internal error: `%s'"
+                          (buffer-string))))))
                (with-current-buffer outbuf
                  (insert output-string)))
              (when display (display-buffer outbuf))))
@@ -4185,8 +4193,6 @@ beginning of local filename are not substituted."
         (kill-buffer (tramp-get-connection-buffer v))
         (setq ret 1)))
 
-      ;; Check return code.
-      (unless ret (setq ret (tramp-send-command-and-check v nil)))
       ;; Provide error file.
       (when tmpstderr (rename-file tmpstderr (cadr destination) t))
       ;; Cleanup.  We remove all file cache values for the connection,
-- 
1.6.4





reply via email to

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