emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r102032: * net/tramp-sh.el (tramp-do-


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102032: * net/tramp-sh.el (tramp-do-file-attributes-with-stat): Do not use
Date: Thu, 21 Oct 2010 10:05:23 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102032
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Thu 2010-10-21 10:05:23 +0200
message:
  * net/tramp-sh.el (tramp-do-file-attributes-with-stat): Do not use
  space in stat format string.
  (tramp-send-command): Unset $PS1 when using here documents, in
  order not to get several prompts.
  (tramp-get-inline-coding): Return `nil' in case of errors.
modified:
  lisp/ChangeLog
  lisp/net/tramp-sh.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-10-21 02:38:46 +0000
+++ b/lisp/ChangeLog    2010-10-21 08:05:23 +0000
@@ -1,3 +1,11 @@
+010-10-21  Michael Albinus  <address@hidden>
+
+       * net/tramp-sh.el (tramp-do-file-attributes-with-stat): Do not use
+       space in stat format string.
+       (tramp-send-command): Unset $PS1 when using here documents, in
+       order not to get several prompts.
+       (tramp-get-inline-coding): Return `nil' in case of errors.
+
 2010-10-21  Daiki Ueno  <address@hidden>
 
        * hexl.el (hexl-mode, hexl-mode-exit): Tweak

=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el      2010-10-19 09:50:07 +0000
+++ b/lisp/net/tramp-sh.el      2010-10-21 08:05:23 +0000
@@ -67,7 +67,7 @@
   :group 'tramp
   :type 'string)
 
-;; ksh on OpenBSD 4.5 requires, that PS1 contains a `#' character for
+;; ksh on OpenBSD 4.5 requires, that $PS1 contains a `#' character for
 ;; root users.  It uses the `$' character for other users.  In order
 ;; to guarantee a proper prompt, we use "#$" for the prompt.
 
@@ -1241,7 +1241,7 @@
    (format
     ;; On Opsware, pdksh (which is the true name of ksh there) doesn't
     ;; parse correctly the sequence "((".  Therefore, we add a space.
-    "( (%s %s || %s -h %s) && %s -c '( (\"%%N\") %%h %s %s %%Xe0 %%Ye0 %%Ze0 
%%se0 \"%%A\" t %%ie0 -1)' %s || echo nil)"
+    "( (%s %s || %s -h %s) && %s -c '((\"%%N\") %%h %s %s %%Xe0 %%Ye0 %%Ze0 
%%se0 \"%%A\" t %%ie0 -1)' %s || echo nil)"
     (tramp-get-file-exists-command vec)
     (tramp-shell-quote-argument localname)
     (tramp-get-test-command vec)
@@ -4359,6 +4359,11 @@
       ;; We mark the command string that it can be erased in the output buffer.
       (tramp-set-connection-property p "check-remote-echo" t)
       (setq command (format "%s%s%s" tramp-echo-mark command tramp-echo-mark)))
+    (when (string-match "<<'EOF'" command)
+      ;; Unset $PS1 when using here documents, in order not to get
+      ;; several prompts.
+      (setq command (concat "(PS1= ; " command "\n)")))
+    ;; Send the command.
     (tramp-message vec 6 "%s" command)
     (tramp-send-string vec command)
     (unless nooutput (tramp-wait-for-output p))))
@@ -4897,54 +4902,57 @@
 Otherwise, either a string is returned which contains a `%s' mark
 to be used for the respective input or output file; or a Lisp
 function cell is returned to be applied on a buffer."
-  (let ((coding
-        (with-connection-property vec prop
-          (tramp-find-inline-encoding vec)
-          (tramp-get-connection-property vec prop nil)))
-       (prop1 (if (string-match "encoding" prop)
-                  "inline-compress" "inline-decompress"))
-       compress)
-    ;; The connection property might have been cached.  So we must send
-    ;; the script to the remote side - maybe.
-    (when (and coding (symbolp coding) (string-match "remote" prop))
-      (let ((name (symbol-name coding)))
-       (while (string-match (regexp-quote "-") name)
-         (setq name (replace-match "_" nil t name)))
-       (tramp-maybe-send-script vec (symbol-value coding) name)
-       (setq coding name)))
-    (when coding
-      ;; Check for the `compress' command.
-      (setq compress (tramp-get-inline-compress vec prop1 size))
-      ;; Return the value.
-      (cond
-       ((and compress (symbolp coding))
-       (if (string-match "decompress" prop1)
+  ;; We must catch the errors, because we want to return `nil', when
+  ;; no inline coding is found.
+  (ignore-errors
+    (let ((coding
+          (with-connection-property vec prop
+            (tramp-find-inline-encoding vec)
+            (tramp-get-connection-property vec prop nil)))
+         (prop1 (if (string-match "encoding" prop)
+                    "inline-compress" "inline-decompress"))
+         compress)
+      ;; The connection property might have been cached.  So we must
+      ;; send the script to the remote side - maybe.
+      (when (and coding (symbolp coding) (string-match "remote" prop))
+       (let ((name (symbol-name coding)))
+         (while (string-match (regexp-quote "-") name)
+           (setq name (replace-match "_" nil t name)))
+         (tramp-maybe-send-script vec (symbol-value coding) name)
+         (setq coding name)))
+      (when coding
+       ;; Check for the `compress' command.
+       (setq compress (tramp-get-inline-compress vec prop1 size))
+       ;; Return the value.
+       (cond
+        ((and compress (symbolp coding))
+         (if (string-match "decompress" prop1)
+             `(lambda (beg end)
+                (,coding beg end)
+                (let ((coding-system-for-write 'binary)
+                      (coding-system-for-read 'binary))
+                  (apply
+                   'call-process-region (point-min) (point-max)
+                   (car (split-string ,compress)) t t nil
+                   (cdr (split-string ,compress)))))
            `(lambda (beg end)
-              (,coding beg end)
               (let ((coding-system-for-write 'binary)
                     (coding-system-for-read 'binary))
                 (apply
-                 'call-process-region (point-min) (point-max)
+                 'call-process-region beg end
                  (car (split-string ,compress)) t t nil
-                 (cdr (split-string ,compress)))))
-         `(lambda (beg end)
-            (let ((coding-system-for-write 'binary)
-                  (coding-system-for-read 'binary))
-              (apply
-               'call-process-region beg end
-               (car (split-string ,compress)) t t nil
-               (cdr (split-string ,compress))))
-            (,coding (point-min) (point-max)))))
-       ((symbolp coding)
-       coding)
-       ((and compress (string-match "decoding" prop))
-       (format "(%s | %s >%%s)" coding compress))
-       (compress
-       (format "(%s <%%s | %s)" compress coding))
-       ((string-match "decoding" prop)
-       (format "%s >%%s" coding))
-       (t
-       (format "%s <%%s" coding))))))
+                 (cdr (split-string ,compress))))
+              (,coding (point-min) (point-max)))))
+        ((symbolp coding)
+         coding)
+        ((and compress (string-match "decoding" prop))
+         (format "(%s | %s >%%s)" coding compress))
+        (compress
+         (format "(%s <%%s | %s)" compress coding))
+        ((string-match "decoding" prop)
+         (format "%s >%%s" coding))
+        (t
+         (format "%s <%%s" coding)))))))
 
 ;;; Integration of eshell.el:
 


reply via email to

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