[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-24 935ee05: * net/tramp-sh.el (tramp-get-remote-path
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] emacs-24 935ee05: * net/tramp-sh.el (tramp-get-remote-path): Use a login shell in |
Date: |
Wed, 10 Dec 2014 13:16:17 +0000 |
branch: emacs-24
commit 935ee05f07019d0dc1ccf304317a6790767f5a20
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
* net/tramp-sh.el (tramp-get-remote-path): Use a login shell in
order to determine `tramp-own-remote-path'.
---
lisp/ChangeLog | 5 ++++
lisp/net/tramp-sh.el | 52 +++++++++++++++++++++++++++++--------------------
2 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d946a2e..116317b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-10 Michael Albinus <address@hidden>
+
+ * net/tramp-sh.el (tramp-get-remote-path): Use a login shell in
+ order to determine `tramp-own-remote-path'.
+
2014-12-09 Fabián Ezequiel Gallina <address@hidden>
* progmodes/python.el (python-shell-parse-command): Quote
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index ff00b55..f94c5b5 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3847,6 +3847,18 @@ file exists and nonzero exit status otherwise."
(setq item (pop alist))
(when (string-match (car item) shell)
(setq extra-args (cdr item))))
+ ;; It is useful to set the prompt in the following command
+ ;; because some people have a setting for $PS1 which /bin/sh
+ ;; doesn't know about and thus /bin/sh will display a strange
+ ;; prompt. For example, if $PS1 has "${CWD}" in the value, then
+ ;; ksh will display the current working directory but /bin/sh
+ ;; will display a dollar sign. The following command line sets
+ ;; $PS1 to a sane value, and works under Bourne-ish shells as
+ ;; well as csh-like shells. We also unset the variable $ENV
+ ;; because that is read by some sh implementations (eg, bash
+ ;; when called as sh) on startup; this way, we avoid the startup
+ ;; file clobbering $PS1. $PROMPT_COMMAND is another way to set
+ ;; the prompt in /bin/bash, it must be discarded as well.
(tramp-send-command
vec (format
"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."
Mainly sets the prompt and the echo correctly. PROC is the shell
process to set up. VEC specifies the connection."
(let ((tramp-end-of-output tramp-initial-end-of-output))
- ;; It is useful to set the prompt in the following command because
- ;; some people have a setting for $PS1 which /bin/sh doesn't know
- ;; about and thus /bin/sh will display a strange prompt. For
- ;; example, if $PS1 has "${CWD}" in the value, then ksh will
- ;; display the current working directory but /bin/sh will display
- ;; a dollar sign. The following command line sets $PS1 to a sane
- ;; value, and works under Bourne-ish shells as well as csh-like
- ;; shells. Daniel Pittman reports that the unusual positioning of
- ;; the single quotes makes it work under `rc', too. We also unset
- ;; the variable $ENV because that is read by some sh
- ;; implementations (eg, bash when called as sh) on startup; this
- ;; way, we avoid the startup file clobbering $PS1. $PROMPT_COMMAND
- ;; is another way to set the prompt in /bin/bash, it must be
- ;; discarded as well.
(tramp-open-shell
vec
(or (tramp-get-connection-property vec "remote-shell" nil)
@@ -5025,13 +5023,25 @@ Return ATTR."
"/bin:/usr/bin")
"/bin:/usr/bin"))))
(own-remote-path
- (when elt2
- (condition-case nil
- (tramp-send-command-and-read vec "echo \\\"$PATH\\\"")
- (error
- (tramp-message
- vec 3 "$PATH not set, ignoring `tramp-own-remote-path'.")
- nil)))))
+ ;; We cannot apply `tramp-send-command-and-read' because
+ ;; the login shell could return more than just the $PATH
+ ;; string. So we emulate that function.
+ (when elt2
+ (tramp-send-command
+ vec
+ (format
+ "%s -l %s 'echo \\\"$PATH\\\"'"
+ (tramp-get-method-parameter
+ (tramp-file-name-method vec) 'tramp-remote-shell)
+ (mapconcat
+ 'identity
+ (tramp-get-method-parameter
+ (tramp-file-name-method vec) 'tramp-remote-shell-args)
+ " ")))
+ (with-current-buffer (tramp-get-connection-buffer vec)
+ (goto-char (point-max))
+ (forward-line -1)
+ (read (current-buffer))))))
;; Replace place holder `tramp-default-remote-path'.
(when elt1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-24 935ee05: * net/tramp-sh.el (tramp-get-remote-path): Use a login shell in,
Michael Albinus <=