diff options
| author | Michael Albinus | 2014-12-10 14:15:51 +0100 |
|---|---|---|
| committer | Michael Albinus | 2014-12-10 14:15:51 +0100 |
| commit | 935ee05f07019d0dc1ccf304317a6790767f5a20 (patch) | |
| tree | b8aeec25af14c8c02166a41aaf1115ae3712c2c9 | |
| parent | c2db9393595559ccddcccbb8d1a85e1167867714 (diff) | |
| download | emacs-935ee05f07019d0dc1ccf304317a6790767f5a20.tar.gz emacs-935ee05f07019d0dc1ccf304317a6790767f5a20.zip | |
* net/tramp-sh.el (tramp-get-remote-path): Use a login shell in
order to determine `tramp-own-remote-path'.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 52 |
2 files changed, 36 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d946a2eb586..116317bc30c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-12-10 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp-sh.el (tramp-get-remote-path): Use a login shell in | ||
| 4 | order to determine `tramp-own-remote-path'. | ||
| 5 | |||
| 1 | 2014-12-09 Fabián Ezequiel Gallina <fgallina@gnu.org> | 6 | 2014-12-09 Fabián Ezequiel Gallina <fgallina@gnu.org> |
| 2 | 7 | ||
| 3 | * progmodes/python.el (python-shell-parse-command): Quote | 8 | * progmodes/python.el (python-shell-parse-command): Quote |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index ff00b55756d..f94c5b5d47a 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -3847,6 +3847,18 @@ file exists and nonzero exit status otherwise." | |||
| 3847 | (setq item (pop alist)) | 3847 | (setq item (pop alist)) |
| 3848 | (when (string-match (car item) shell) | 3848 | (when (string-match (car item) shell) |
| 3849 | (setq extra-args (cdr item)))) | 3849 | (setq extra-args (cdr item)))) |
| 3850 | ;; It is useful to set the prompt in the following command | ||
| 3851 | ;; because some people have a setting for $PS1 which /bin/sh | ||
| 3852 | ;; doesn't know about and thus /bin/sh will display a strange | ||
| 3853 | ;; prompt. For example, if $PS1 has "${CWD}" in the value, then | ||
| 3854 | ;; ksh will display the current working directory but /bin/sh | ||
| 3855 | ;; will display a dollar sign. The following command line sets | ||
| 3856 | ;; $PS1 to a sane value, and works under Bourne-ish shells as | ||
| 3857 | ;; well as csh-like shells. We also unset the variable $ENV | ||
| 3858 | ;; because that is read by some sh implementations (eg, bash | ||
| 3859 | ;; when called as sh) on startup; this way, we avoid the startup | ||
| 3860 | ;; file clobbering $PS1. $PROMPT_COMMAND is another way to set | ||
| 3861 | ;; the prompt in /bin/bash, it must be discarded as well. | ||
| 3850 | (tramp-send-command | 3862 | (tramp-send-command |
| 3851 | vec (format | 3863 | vec (format |
| 3852 | "exec env ENV='' HISTFILE=/dev/null PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s" | 3864 | "exec env ENV='' HISTFILE=/dev/null PROMPT_COMMAND='' PS1=%s PS2='' PS3='' %s %s" |
| @@ -3923,20 +3935,6 @@ seconds. If not, it produces an error message with the given ERROR-ARGS." | |||
| 3923 | Mainly sets the prompt and the echo correctly. PROC is the shell | 3935 | Mainly sets the prompt and the echo correctly. PROC is the shell |
| 3924 | process to set up. VEC specifies the connection." | 3936 | process to set up. VEC specifies the connection." |
| 3925 | (let ((tramp-end-of-output tramp-initial-end-of-output)) | 3937 | (let ((tramp-end-of-output tramp-initial-end-of-output)) |
| 3926 | ;; It is useful to set the prompt in the following command because | ||
| 3927 | ;; some people have a setting for $PS1 which /bin/sh doesn't know | ||
| 3928 | ;; about and thus /bin/sh will display a strange prompt. For | ||
| 3929 | ;; example, if $PS1 has "${CWD}" in the value, then ksh will | ||
| 3930 | ;; display the current working directory but /bin/sh will display | ||
| 3931 | ;; a dollar sign. The following command line sets $PS1 to a sane | ||
| 3932 | ;; value, and works under Bourne-ish shells as well as csh-like | ||
| 3933 | ;; shells. Daniel Pittman reports that the unusual positioning of | ||
| 3934 | ;; the single quotes makes it work under `rc', too. We also unset | ||
| 3935 | ;; the variable $ENV because that is read by some sh | ||
| 3936 | ;; implementations (eg, bash when called as sh) on startup; this | ||
| 3937 | ;; way, we avoid the startup file clobbering $PS1. $PROMPT_COMMAND | ||
| 3938 | ;; is another way to set the prompt in /bin/bash, it must be | ||
| 3939 | ;; discarded as well. | ||
| 3940 | (tramp-open-shell | 3938 | (tramp-open-shell |
| 3941 | vec | 3939 | vec |
| 3942 | (or (tramp-get-connection-property vec "remote-shell" nil) | 3940 | (or (tramp-get-connection-property vec "remote-shell" nil) |
| @@ -5025,13 +5023,25 @@ Return ATTR." | |||
| 5025 | "/bin:/usr/bin") | 5023 | "/bin:/usr/bin") |
| 5026 | "/bin:/usr/bin")))) | 5024 | "/bin:/usr/bin")))) |
| 5027 | (own-remote-path | 5025 | (own-remote-path |
| 5028 | (when elt2 | 5026 | ;; We cannot apply `tramp-send-command-and-read' because |
| 5029 | (condition-case nil | 5027 | ;; the login shell could return more than just the $PATH |
| 5030 | (tramp-send-command-and-read vec "echo \\\"$PATH\\\"") | 5028 | ;; string. So we emulate that function. |
| 5031 | (error | 5029 | (when elt2 |
| 5032 | (tramp-message | 5030 | (tramp-send-command |
| 5033 | vec 3 "$PATH not set, ignoring `tramp-own-remote-path'.") | 5031 | vec |
| 5034 | nil))))) | 5032 | (format |
| 5033 | "%s -l %s 'echo \\\"$PATH\\\"'" | ||
| 5034 | (tramp-get-method-parameter | ||
| 5035 | (tramp-file-name-method vec) 'tramp-remote-shell) | ||
| 5036 | (mapconcat | ||
| 5037 | 'identity | ||
| 5038 | (tramp-get-method-parameter | ||
| 5039 | (tramp-file-name-method vec) 'tramp-remote-shell-args) | ||
| 5040 | " "))) | ||
| 5041 | (with-current-buffer (tramp-get-connection-buffer vec) | ||
| 5042 | (goto-char (point-max)) | ||
| 5043 | (forward-line -1) | ||
| 5044 | (read (current-buffer)))))) | ||
| 5035 | 5045 | ||
| 5036 | ;; Replace place holder `tramp-default-remote-path'. | 5046 | ;; Replace place holder `tramp-default-remote-path'. |
| 5037 | (when elt1 | 5047 | (when elt1 |