diff options
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/tramp-sh.el | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 6beece526ff..314c1a6f8e7 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -2686,27 +2686,46 @@ the result will be a local, non-Tramp, filename." | |||
| 2686 | (defun tramp-sh-handle-start-file-process (name buffer program &rest args) | 2686 | (defun tramp-sh-handle-start-file-process (name buffer program &rest args) |
| 2687 | "Like `start-file-process' for Tramp files." | 2687 | "Like `start-file-process' for Tramp files." |
| 2688 | (with-parsed-tramp-file-name default-directory nil | 2688 | (with-parsed-tramp-file-name default-directory nil |
| 2689 | ;; When PROGRAM is nil, we just provide a tty. | 2689 | (let* (;; When PROGRAM matches "*sh", and the first arg is "-c", |
| 2690 | (let ((command | 2690 | ;; it might be that the arguments exceed the command line |
| 2691 | (when (stringp program) | 2691 | ;; length. Therefore, we modify the command. |
| 2692 | (format "cd %s; exec env PS1=%s %s" | 2692 | (heredoc (and (stringp program) |
| 2693 | (tramp-shell-quote-argument localname) | 2693 | (string-match "sh$" program) |
| 2694 | ;; Use a human-friendly prompt, for example for `shell'. | 2694 | (string-equal "-c" (car args)) |
| 2695 | (tramp-shell-quote-argument | 2695 | (= (length args) 2))) |
| 2696 | (format "%s %s" | 2696 | ;; When PROGRAM is nil, we just provide a tty. |
| 2697 | (file-remote-p default-directory) | 2697 | (args (if (not heredoc) args |
| 2698 | tramp-initial-end-of-output)) | 2698 | (let ((i 250)) |
| 2699 | (mapconcat 'tramp-shell-quote-argument | 2699 | (while (and (< i (length (cadr args))) |
| 2700 | (cons program args) " ")))) | 2700 | (string-match " " (cadr args) i)) |
| 2701 | (tramp-process-connection-type | 2701 | (setcdr |
| 2702 | (or (null program) tramp-process-connection-type)) | 2702 | args |
| 2703 | (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer))) | 2703 | (list (replace-match " \\\\\n" nil nil (cadr args)))) |
| 2704 | (name1 name) | 2704 | (setq i (+ i 250)))) |
| 2705 | (i 0) | 2705 | (cdr args))) |
| 2706 | ;; We do not want to raise an error when | 2706 | (command |
| 2707 | ;; `start-file-process' has been started several time in | 2707 | (when (stringp program) |
| 2708 | ;; `eshell' and friends. | 2708 | (format "cd %s; exec %s env PS1=%s %s" |
| 2709 | (tramp-current-connection nil)) | 2709 | (tramp-shell-quote-argument localname) |
| 2710 | (if heredoc "<<EOF" "") | ||
| 2711 | ;; Use a human-friendly prompt, for example for `shell'. | ||
| 2712 | (tramp-shell-quote-argument | ||
| 2713 | (format "%s %s" | ||
| 2714 | (file-remote-p default-directory) | ||
| 2715 | tramp-initial-end-of-output)) | ||
| 2716 | (if heredoc | ||
| 2717 | (format "%s\n%s\nEOF" program (car args)) | ||
| 2718 | (mapconcat 'tramp-shell-quote-argument | ||
| 2719 | (cons program args) " "))))) | ||
| 2720 | (tramp-process-connection-type | ||
| 2721 | (or (null program) tramp-process-connection-type)) | ||
| 2722 | (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer))) | ||
| 2723 | (name1 name) | ||
| 2724 | (i 0) | ||
| 2725 | ;; We do not want to raise an error when | ||
| 2726 | ;; `start-file-process' has been started several time in | ||
| 2727 | ;; `eshell' and friends. | ||
| 2728 | (tramp-current-connection nil)) | ||
| 2710 | 2729 | ||
| 2711 | (unless buffer | 2730 | (unless buffer |
| 2712 | ;; BUFFER can be nil. We use a temporary buffer. | 2731 | ;; BUFFER can be nil. We use a temporary buffer. |