emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r116273: Make heredocs more robust in Tramp.


From: Michael Albinus
Subject: [Emacs-diffs] trunk r116273: Make heredocs more robust in Tramp.
Date: Wed, 05 Feb 2014 14:11:54 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116273
revision-id: address@hidden
parent: address@hidden
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Wed 2014-02-05 15:11:50 +0100
message:
  Make heredocs more robust in Tramp.
  
  * net/tramp-sh.el (tramp-end-of-heredoc): New defconst.
  (tramp-sh-handle-set-file-acl)
  (tramp-sh-handle-start-file-process)
  (tramp-sh-handle-write-region, tramp-sh-handle-vc-registered)
  (tramp-find-executable, tramp-send-command): Use it.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/net/tramp-sh.el           trampsh.el-20100913133439-a1faifh29eqoi4nh-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-02-05 08:37:39 +0000
+++ b/lisp/ChangeLog    2014-02-05 14:11:50 +0000
@@ -1,6 +1,14 @@
+2014-02-05  Michael Albinus  <address@hidden>
+
+       * net/tramp-sh.el (tramp-end-of-heredoc): New defconst.
+       (tramp-sh-handle-set-file-acl)
+       (tramp-sh-handle-start-file-process)
+       (tramp-sh-handle-write-region, tramp-sh-handle-vc-registered)
+       (tramp-find-executable, tramp-send-command): Use it.
+
 2014-02-05  Glenn Morris  <address@hidden>
 
-       * epa.el (epa-mail-aliases): Fic custom type.  Doc tweak.
+       * epa.el (epa-mail-aliases): Fix custom type.  Doc tweak.
 
 2014-02-04  Fabián Ezequiel Gallina  <address@hidden>
 

=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el      2014-01-01 08:31:29 +0000
+++ b/lisp/net/tramp-sh.el      2014-02-05 14:11:50 +0000
@@ -79,6 +79,9 @@
 (defconst tramp-initial-end-of-output "#$ "
   "Prompt when establishing a connection.")
 
+(defconst tramp-end-of-heredoc (md5 tramp-end-of-output)
+  "String used to recognize end of heredoc strings.")
+
 ;; Initialize `tramp-methods' with the supported methods.
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
@@ -1443,8 +1446,11 @@
     (if (and (stringp acl-string) (tramp-remote-acl-p v)
             (progn
               (tramp-send-command
-               v (format "setfacl --set-file=- %s <<'EOF'\n%s\nEOF\n"
-                         (tramp-shell-quote-argument localname) acl-string))
+               v (format "setfacl --set-file=- %s <<'%s'\n%s\n%s\n"
+                         (tramp-shell-quote-argument localname)
+                         tramp-end-of-heredoc
+                         acl-string
+                         tramp-end-of-heredoc))
               (tramp-send-command-and-check v nil)))
        ;; Success.
        (progn
@@ -2707,14 +2713,15 @@
            (when (stringp program)
              (format "cd %s; exec %s env PS1=%s %s"
                      (tramp-shell-quote-argument localname)
-                     (if heredoc "<<EOF" "")
+                     (if heredoc (format "<<'%s'" tramp-end-of-heredoc) "")
                      ;; Use a human-friendly prompt, for example for `shell'.
                      (tramp-shell-quote-argument
                       (format "%s %s"
                               (file-remote-p default-directory)
                               tramp-initial-end-of-output))
                      (if heredoc
-                         (format "%s\n%s\nEOF" program (car args))
+                         (format "%s\n%s\n%s"
+                                 program (car args) tramp-end-of-heredoc)
                        (mapconcat 'tramp-shell-quote-argument
                                   (cons program args) " ")))))
           (tramp-process-connection-type
@@ -3182,9 +3189,11 @@
                      (tramp-send-command
                       v
                       (format
-                       (concat rem-dec " <<'EOF'\n%sEOF")
+                       (concat rem-dec " <<'%s'\n%s%s")
                        (tramp-shell-quote-argument localname)
-                       (buffer-string)))
+                       tramp-end-of-heredoc
+                       (buffer-string)
+                       tramp-end-of-heredoc))
                      (tramp-barf-unless-okay
                       v nil
                       "Couldn't write region to `%s', decode using `%s' failed"
@@ -3302,10 +3311,12 @@
                 (tramp-send-command-and-read
                  v
                  (format
-                  "tramp_vc_registered_read_file_names <<'EOF'\n%s\nEOF\n"
+                  "tramp_vc_registered_read_file_names <<'%s'\n%s\n%s\n"
+                  tramp-end-of-heredoc
                   (mapconcat 'tramp-shell-quote-argument
                              tramp-vc-registered-file-names
-                             "\n"))))
+                             "\n")
+                  tramp-end-of-heredoc)))
 
              (tramp-set-file-property
               v (car elt) (cadr elt) (cadr (cdr elt))))))
@@ -3580,9 +3591,12 @@
         (format (concat "while read d; "
                         "do if test -x $d/%s -a -f $d/%s; "
                         "then echo tramp_executable $d/%s; "
-                        "break; fi; done <<'EOF'\n"
-                        "%s\nEOF")
-                progname progname progname (mapconcat 'identity dirlist "\n")))
+                        "break; fi; done <<'%s'\n"
+                        "%s\n%s")
+                progname progname progname
+                tramp-end-of-heredoc
+                (mapconcat 'identity dirlist "\n")
+                tramp-end-of-heredoc))
        (goto-char (point-max))
        (when (search-backward "tramp_executable " nil t)
          (skip-chars-forward "^ ")
@@ -4560,7 +4574,7 @@
     ;; Some busyboxes tend to close the connection when we use the
     ;; following syntax for here-documents.  This we cannot test; it
     ;; shall be set via `tramp-connection-properties'.
-    (when (and (string-match "<<'EOF'" command)
+    (when (and (string-match (format "<<'%s'" tramp-end-of-heredoc) command)
               (not (tramp-get-connection-property vec "busybox" nil)))
       ;; Unset $PS1 when using here documents, in order to avoid
       ;; multiple prompts.


reply via email to

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