diff options
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/tramp-sh.el | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 6e46df254b2..8d7e046126c 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -2835,16 +2835,27 @@ the result will be a local, non-Tramp, file name." | |||
| 2835 | (list (replace-match " \\\\\n" nil nil (cadr args)))) | 2835 | (list (replace-match " \\\\\n" nil nil (cadr args)))) |
| 2836 | (setq i (+ i 250)))) | 2836 | (setq i (+ i 250)))) |
| 2837 | (cdr args))) | 2837 | (cdr args))) |
| 2838 | ;; Use a human-friendly prompt, for example for `shell'. | ||
| 2839 | (prompt (format "PS1=%s" | ||
| 2840 | (format "%s %s" | ||
| 2841 | (file-remote-p default-directory) | ||
| 2842 | tramp-initial-end-of-output))) | ||
| 2843 | ;; We use as environment the difference to toplevel | ||
| 2844 | ;; `process-environment'. | ||
| 2845 | env | ||
| 2846 | (env | ||
| 2847 | (dolist | ||
| 2848 | (elt | ||
| 2849 | (cons prompt (nreverse (copy-sequence process-environment))) | ||
| 2850 | env) | ||
| 2851 | (or (member elt (default-toplevel-value 'process-environment)) | ||
| 2852 | (setq env (cons elt env))))) | ||
| 2838 | (command | 2853 | (command |
| 2839 | (when (stringp program) | 2854 | (when (stringp program) |
| 2840 | (format "cd %s && exec %s env PS1=%s %s" | 2855 | (format "cd %s && exec %s env %s %s" |
| 2841 | (tramp-shell-quote-argument localname) | 2856 | (tramp-shell-quote-argument localname) |
| 2842 | (if heredoc (format "<<'%s'" tramp-end-of-heredoc) "") | 2857 | (if heredoc (format "<<'%s'" tramp-end-of-heredoc) "") |
| 2843 | ;; Use a human-friendly prompt, for example for `shell'. | 2858 | (mapconcat 'tramp-shell-quote-argument env " ") |
| 2844 | (tramp-shell-quote-argument | ||
| 2845 | (format "%s %s" | ||
| 2846 | (file-remote-p default-directory) | ||
| 2847 | tramp-initial-end-of-output)) | ||
| 2848 | (if heredoc | 2859 | (if heredoc |
| 2849 | (format "%s\n(\n%s\n) </dev/tty\n%s" | 2860 | (format "%s\n(\n%s\n) </dev/tty\n%s" |
| 2850 | program (car args) tramp-end-of-heredoc) | 2861 | program (car args) tramp-end-of-heredoc) |
| @@ -2931,10 +2942,20 @@ the result will be a local, non-Tramp, file name." | |||
| 2931 | (error "Implementation does not handle immediate return")) | 2942 | (error "Implementation does not handle immediate return")) |
| 2932 | 2943 | ||
| 2933 | (with-parsed-tramp-file-name default-directory nil | 2944 | (with-parsed-tramp-file-name default-directory nil |
| 2934 | (let (command input tmpinput stderr tmpstderr outbuf ret) | 2945 | (let (command env input tmpinput stderr tmpstderr outbuf ret) |
| 2935 | ;; Compute command. | 2946 | ;; Compute command. |
| 2936 | (setq command (mapconcat 'tramp-shell-quote-argument | 2947 | (setq command (mapconcat 'tramp-shell-quote-argument |
| 2937 | (cons program args) " ")) | 2948 | (cons program args) " ")) |
| 2949 | ;; We use as environment the difference to toplevel `process-environment'. | ||
| 2950 | (setq env | ||
| 2951 | (dolist (elt (nreverse (copy-sequence process-environment)) env) | ||
| 2952 | (or (member elt (default-toplevel-value 'process-environment)) | ||
| 2953 | (setq env (cons elt env))))) | ||
| 2954 | (when env | ||
| 2955 | (setq command | ||
| 2956 | (format | ||
| 2957 | "env %s %s" | ||
| 2958 | (mapconcat 'tramp-shell-quote-argument env " ") command))) | ||
| 2938 | ;; Determine input. | 2959 | ;; Determine input. |
| 2939 | (if (null infile) | 2960 | (if (null infile) |
| 2940 | (setq input "/dev/null") | 2961 | (setq input "/dev/null") |