diff options
| author | Michael Albinus | 2014-02-05 15:11:50 +0100 |
|---|---|---|
| committer | Michael Albinus | 2014-02-05 15:11:50 +0100 |
| commit | 9a83b32b7bd5663bd74f8bc04d5c3f61deb2c78d (patch) | |
| tree | 7192ad7bd84dc7eced25d1f0c2684bca16f00f9b | |
| parent | e873a22e9550b277df9319849fe1287f6519210d (diff) | |
| download | emacs-9a83b32b7bd5663bd74f8bc04d5c3f61deb2c78d.tar.gz emacs-9a83b32b7bd5663bd74f8bc04d5c3f61deb2c78d.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 38 |
2 files changed, 35 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a74ffeda68b..5ce9ab4913c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,6 +1,14 @@ | |||
| 1 | 2014-02-05 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp-sh.el (tramp-end-of-heredoc): New defconst. | ||
| 4 | (tramp-sh-handle-set-file-acl) | ||
| 5 | (tramp-sh-handle-start-file-process) | ||
| 6 | (tramp-sh-handle-write-region, tramp-sh-handle-vc-registered) | ||
| 7 | (tramp-find-executable, tramp-send-command): Use it. | ||
| 8 | |||
| 1 | 2014-02-05 Glenn Morris <rgm@gnu.org> | 9 | 2014-02-05 Glenn Morris <rgm@gnu.org> |
| 2 | 10 | ||
| 3 | * epa.el (epa-mail-aliases): Fic custom type. Doc tweak. | 11 | * epa.el (epa-mail-aliases): Fix custom type. Doc tweak. |
| 4 | 12 | ||
| 5 | 2014-02-04 Fabián Ezequiel Gallina <fgallina@gnu.org> | 13 | 2014-02-04 Fabián Ezequiel Gallina <fgallina@gnu.org> |
| 6 | 14 | ||
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 65d5f27e967..67a517a719c 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -79,6 +79,9 @@ detected as prompt when being sent on echoing hosts, therefore.") | |||
| 79 | (defconst tramp-initial-end-of-output "#$ " | 79 | (defconst tramp-initial-end-of-output "#$ " |
| 80 | "Prompt when establishing a connection.") | 80 | "Prompt when establishing a connection.") |
| 81 | 81 | ||
| 82 | (defconst tramp-end-of-heredoc (md5 tramp-end-of-output) | ||
| 83 | "String used to recognize end of heredoc strings.") | ||
| 84 | |||
| 82 | ;; Initialize `tramp-methods' with the supported methods. | 85 | ;; Initialize `tramp-methods' with the supported methods. |
| 83 | ;;;###tramp-autoload | 86 | ;;;###tramp-autoload |
| 84 | (add-to-list 'tramp-methods | 87 | (add-to-list 'tramp-methods |
| @@ -1443,8 +1446,11 @@ be non-negative integers." | |||
| 1443 | (if (and (stringp acl-string) (tramp-remote-acl-p v) | 1446 | (if (and (stringp acl-string) (tramp-remote-acl-p v) |
| 1444 | (progn | 1447 | (progn |
| 1445 | (tramp-send-command | 1448 | (tramp-send-command |
| 1446 | v (format "setfacl --set-file=- %s <<'EOF'\n%s\nEOF\n" | 1449 | v (format "setfacl --set-file=- %s <<'%s'\n%s\n%s\n" |
| 1447 | (tramp-shell-quote-argument localname) acl-string)) | 1450 | (tramp-shell-quote-argument localname) |
| 1451 | tramp-end-of-heredoc | ||
| 1452 | acl-string | ||
| 1453 | tramp-end-of-heredoc)) | ||
| 1448 | (tramp-send-command-and-check v nil))) | 1454 | (tramp-send-command-and-check v nil))) |
| 1449 | ;; Success. | 1455 | ;; Success. |
| 1450 | (progn | 1456 | (progn |
| @@ -2707,14 +2713,15 @@ the result will be a local, non-Tramp, filename." | |||
| 2707 | (when (stringp program) | 2713 | (when (stringp program) |
| 2708 | (format "cd %s; exec %s env PS1=%s %s" | 2714 | (format "cd %s; exec %s env PS1=%s %s" |
| 2709 | (tramp-shell-quote-argument localname) | 2715 | (tramp-shell-quote-argument localname) |
| 2710 | (if heredoc "<<EOF" "") | 2716 | (if heredoc (format "<<'%s'" tramp-end-of-heredoc) "") |
| 2711 | ;; Use a human-friendly prompt, for example for `shell'. | 2717 | ;; Use a human-friendly prompt, for example for `shell'. |
| 2712 | (tramp-shell-quote-argument | 2718 | (tramp-shell-quote-argument |
| 2713 | (format "%s %s" | 2719 | (format "%s %s" |
| 2714 | (file-remote-p default-directory) | 2720 | (file-remote-p default-directory) |
| 2715 | tramp-initial-end-of-output)) | 2721 | tramp-initial-end-of-output)) |
| 2716 | (if heredoc | 2722 | (if heredoc |
| 2717 | (format "%s\n%s\nEOF" program (car args)) | 2723 | (format "%s\n%s\n%s" |
| 2724 | program (car args) tramp-end-of-heredoc) | ||
| 2718 | (mapconcat 'tramp-shell-quote-argument | 2725 | (mapconcat 'tramp-shell-quote-argument |
| 2719 | (cons program args) " "))))) | 2726 | (cons program args) " "))))) |
| 2720 | (tramp-process-connection-type | 2727 | (tramp-process-connection-type |
| @@ -3182,9 +3189,11 @@ the result will be a local, non-Tramp, filename." | |||
| 3182 | (tramp-send-command | 3189 | (tramp-send-command |
| 3183 | v | 3190 | v |
| 3184 | (format | 3191 | (format |
| 3185 | (concat rem-dec " <<'EOF'\n%sEOF") | 3192 | (concat rem-dec " <<'%s'\n%s%s") |
| 3186 | (tramp-shell-quote-argument localname) | 3193 | (tramp-shell-quote-argument localname) |
| 3187 | (buffer-string))) | 3194 | tramp-end-of-heredoc |
| 3195 | (buffer-string) | ||
| 3196 | tramp-end-of-heredoc)) | ||
| 3188 | (tramp-barf-unless-okay | 3197 | (tramp-barf-unless-okay |
| 3189 | v nil | 3198 | v nil |
| 3190 | "Couldn't write region to `%s', decode using `%s' failed" | 3199 | "Couldn't write region to `%s', decode using `%s' failed" |
| @@ -3302,10 +3311,12 @@ the result will be a local, non-Tramp, filename." | |||
| 3302 | (tramp-send-command-and-read | 3311 | (tramp-send-command-and-read |
| 3303 | v | 3312 | v |
| 3304 | (format | 3313 | (format |
| 3305 | "tramp_vc_registered_read_file_names <<'EOF'\n%s\nEOF\n" | 3314 | "tramp_vc_registered_read_file_names <<'%s'\n%s\n%s\n" |
| 3315 | tramp-end-of-heredoc | ||
| 3306 | (mapconcat 'tramp-shell-quote-argument | 3316 | (mapconcat 'tramp-shell-quote-argument |
| 3307 | tramp-vc-registered-file-names | 3317 | tramp-vc-registered-file-names |
| 3308 | "\n")))) | 3318 | "\n") |
| 3319 | tramp-end-of-heredoc))) | ||
| 3309 | 3320 | ||
| 3310 | (tramp-set-file-property | 3321 | (tramp-set-file-property |
| 3311 | v (car elt) (cadr elt) (cadr (cdr elt)))))) | 3322 | v (car elt) (cadr elt) (cadr (cdr elt)))))) |
| @@ -3580,9 +3591,12 @@ This function expects to be in the right *tramp* buffer." | |||
| 3580 | (format (concat "while read d; " | 3591 | (format (concat "while read d; " |
| 3581 | "do if test -x $d/%s -a -f $d/%s; " | 3592 | "do if test -x $d/%s -a -f $d/%s; " |
| 3582 | "then echo tramp_executable $d/%s; " | 3593 | "then echo tramp_executable $d/%s; " |
| 3583 | "break; fi; done <<'EOF'\n" | 3594 | "break; fi; done <<'%s'\n" |
| 3584 | "%s\nEOF") | 3595 | "%s\n%s") |
| 3585 | progname progname progname (mapconcat 'identity dirlist "\n"))) | 3596 | progname progname progname |
| 3597 | tramp-end-of-heredoc | ||
| 3598 | (mapconcat 'identity dirlist "\n") | ||
| 3599 | tramp-end-of-heredoc)) | ||
| 3586 | (goto-char (point-max)) | 3600 | (goto-char (point-max)) |
| 3587 | (when (search-backward "tramp_executable " nil t) | 3601 | (when (search-backward "tramp_executable " nil t) |
| 3588 | (skip-chars-forward "^ ") | 3602 | (skip-chars-forward "^ ") |
| @@ -4560,7 +4574,7 @@ function waits for output unless NOOUTPUT is set." | |||
| 4560 | ;; Some busyboxes tend to close the connection when we use the | 4574 | ;; Some busyboxes tend to close the connection when we use the |
| 4561 | ;; following syntax for here-documents. This we cannot test; it | 4575 | ;; following syntax for here-documents. This we cannot test; it |
| 4562 | ;; shall be set via `tramp-connection-properties'. | 4576 | ;; shall be set via `tramp-connection-properties'. |
| 4563 | (when (and (string-match "<<'EOF'" command) | 4577 | (when (and (string-match (format "<<'%s'" tramp-end-of-heredoc) command) |
| 4564 | (not (tramp-get-connection-property vec "busybox" nil))) | 4578 | (not (tramp-get-connection-property vec "busybox" nil))) |
| 4565 | ;; Unset $PS1 when using here documents, in order to avoid | 4579 | ;; Unset $PS1 when using here documents, in order to avoid |
| 4566 | ;; multiple prompts. | 4580 | ;; multiple prompts. |