1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00

* net/tramp-sh.el (tramp-send-command-and-read): New optional arg MARKER.

(tramp-get-remote-path): Use it.
This commit is contained in:
Michael Albinus 2014-12-19 12:45:01 +01:00
parent c773edcf56
commit 2616307f5c
2 changed files with 26 additions and 13 deletions

View File

@ -1,3 +1,9 @@
2014-12-19 Michael Albinus <michael.albinus@gmx.de>
* net/tramp-sh.el (tramp-send-command-and-read): New optional
arg MARKER.
(tramp-get-remote-path): Use it.
2014-12-17 Michael Albinus <michael.albinus@gmx.de> 2014-12-17 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (tramp-error-with-buffer): Call `message' properly. * net/tramp.el (tramp-error-with-buffer): Call `message' properly.

View File

@ -2856,7 +2856,7 @@ the result will be a local, non-Tramp, file name."
(name1 name) (name1 name)
(i 0) (i 0)
;; We do not want to raise an error when ;; We do not want to raise an error when
;; `start-file-process' has been started several time in ;; `start-file-process' has been started several times in
;; `eshell' and friends. ;; `eshell' and friends.
(tramp-current-connection nil)) (tramp-current-connection nil))
@ -4865,8 +4865,9 @@ FMT and ARGS which are passed to `error'."
(or (tramp-send-command-and-check vec command) (or (tramp-send-command-and-check vec command)
(apply 'tramp-error vec 'file-error fmt args))) (apply 'tramp-error vec 'file-error fmt args)))
(defun tramp-send-command-and-read (vec command &optional noerror) (defun tramp-send-command-and-read (vec command &optional noerror marker)
"Run COMMAND and return the output, which must be a Lisp expression. "Run COMMAND and return the output, which must be a Lisp expression.
If MARKER is a regexp, read the output after that string.
In case there is no valid Lisp expression and NOERROR is nil, it In case there is no valid Lisp expression and NOERROR is nil, it
raises an error." raises an error."
(when (if noerror (when (if noerror
@ -4874,8 +4875,17 @@ raises an error."
(tramp-barf-unless-okay (tramp-barf-unless-okay
vec command "`%s' returns with error" command)) vec command "`%s' returns with error" command))
(with-current-buffer (tramp-get-connection-buffer vec) (with-current-buffer (tramp-get-connection-buffer vec)
;; Read the expression.
(goto-char (point-min)) (goto-char (point-min))
;; Read the marker.
(when (stringp marker)
(condition-case nil
(re-search-forward marker)
(error (unless noerror
(tramp-error
vec 'file-error
"`%s' does not return the marker `%s': `%s'"
command marker (buffer-string))))))
;; Read the expression.
(condition-case nil (condition-case nil
(prog1 (read (current-buffer)) (prog1 (read (current-buffer))
;; Error handling. ;; Error handling.
@ -5027,25 +5037,22 @@ Return ATTR."
"/bin:/usr/bin") "/bin:/usr/bin")
"/bin:/usr/bin")))) "/bin:/usr/bin"))))
(own-remote-path (own-remote-path
;; We cannot apply `tramp-send-command-and-read' because ;; The login shell could return more than just the $PATH
;; the login shell could return more than just the $PATH ;; string. So we use `tramp-end-of-heredoc' as marker.
;; string. So we emulate that function.
(when elt2 (when elt2
(tramp-send-command (tramp-send-command-and-read
vec vec
(format (format
"%s -l %s 'echo \\\"$PATH\\\"'" "%s -l %s 'echo %s \\\"$PATH\\\"'"
(tramp-get-method-parameter (tramp-get-method-parameter
(tramp-file-name-method vec) 'tramp-remote-shell) (tramp-file-name-method vec) 'tramp-remote-shell)
(mapconcat (mapconcat
'identity 'identity
(tramp-get-method-parameter (tramp-get-method-parameter
(tramp-file-name-method vec) 'tramp-remote-shell-args) (tramp-file-name-method vec) 'tramp-remote-shell-args)
" "))) " ")
(with-current-buffer (tramp-get-connection-buffer vec) (tramp-shell-quote-argument tramp-end-of-heredoc))
(goto-char (point-max)) nil (regexp-quote tramp-end-of-heredoc)))))
(forward-line -1)
(read (current-buffer))))))
;; Replace place holder `tramp-default-remote-path'. ;; Replace place holder `tramp-default-remote-path'.
(when elt1 (when elt1