diff options
| author | Michael Albinus | 2014-12-19 12:51:42 +0100 |
|---|---|---|
| committer | Michael Albinus | 2014-12-19 12:51:42 +0100 |
| commit | 230c010050f424cee81c3bcf00b0f00a65819dcb (patch) | |
| tree | 74dafa75262593d7cd7cb87ca7ee8574a5804319 | |
| parent | a864bfb57c8445156dbe7e30b0348d9896c27b28 (diff) | |
| download | emacs-230c010050f424cee81c3bcf00b0f00a65819dcb.tar.gz emacs-230c010050f424cee81c3bcf00b0f00a65819dcb.zip | |
* net/tramp-sh.el (tramp-send-command-and-read): New optional arg MARKER.
(tramp-get-remote-path): Use it.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 33 |
2 files changed, 26 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 34c335c663b..ed08c9fbdbb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-12-19 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp-sh.el (tramp-send-command-and-read): New optional | ||
| 4 | arg MARKER. | ||
| 5 | (tramp-get-remote-path): Use it. | ||
| 6 | |||
| 1 | 2014-12-18 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2014-12-18 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | * subr.el (redisplay-dont-pause): Mark as obsolete. | 9 | * subr.el (redisplay-dont-pause): Mark as obsolete. |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index bb1a813b388..dc78acefba6 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -2856,7 +2856,7 @@ the result will be a local, non-Tramp, file name." | |||
| 2856 | (name1 name) | 2856 | (name1 name) |
| 2857 | (i 0) | 2857 | (i 0) |
| 2858 | ;; We do not want to raise an error when | 2858 | ;; We do not want to raise an error when |
| 2859 | ;; `start-file-process' has been started several time in | 2859 | ;; `start-file-process' has been started several times in |
| 2860 | ;; `eshell' and friends. | 2860 | ;; `eshell' and friends. |
| 2861 | (tramp-current-connection nil)) | 2861 | (tramp-current-connection nil)) |
| 2862 | 2862 | ||
| @@ -4865,8 +4865,9 @@ FMT and ARGS which are passed to `error'." | |||
| 4865 | (or (tramp-send-command-and-check vec command) | 4865 | (or (tramp-send-command-and-check vec command) |
| 4866 | (apply 'tramp-error vec 'file-error fmt args))) | 4866 | (apply 'tramp-error vec 'file-error fmt args))) |
| 4867 | 4867 | ||
| 4868 | (defun tramp-send-command-and-read (vec command &optional noerror) | 4868 | (defun tramp-send-command-and-read (vec command &optional noerror marker) |
| 4869 | "Run COMMAND and return the output, which must be a Lisp expression. | 4869 | "Run COMMAND and return the output, which must be a Lisp expression. |
| 4870 | If MARKER is a regexp, read the output after that string. | ||
| 4870 | In case there is no valid Lisp expression and NOERROR is nil, it | 4871 | In case there is no valid Lisp expression and NOERROR is nil, it |
| 4871 | raises an error." | 4872 | raises an error." |
| 4872 | (when (if noerror | 4873 | (when (if noerror |
| @@ -4874,8 +4875,17 @@ raises an error." | |||
| 4874 | (tramp-barf-unless-okay | 4875 | (tramp-barf-unless-okay |
| 4875 | vec command "`%s' returns with error" command)) | 4876 | vec command "`%s' returns with error" command)) |
| 4876 | (with-current-buffer (tramp-get-connection-buffer vec) | 4877 | (with-current-buffer (tramp-get-connection-buffer vec) |
| 4877 | ;; Read the expression. | ||
| 4878 | (goto-char (point-min)) | 4878 | (goto-char (point-min)) |
| 4879 | ;; Read the marker. | ||
| 4880 | (when (stringp marker) | ||
| 4881 | (condition-case nil | ||
| 4882 | (re-search-forward marker) | ||
| 4883 | (error (unless noerror | ||
| 4884 | (tramp-error | ||
| 4885 | vec 'file-error | ||
| 4886 | "`%s' does not return the marker `%s': `%s'" | ||
| 4887 | command marker (buffer-string)))))) | ||
| 4888 | ;; Read the expression. | ||
| 4879 | (condition-case nil | 4889 | (condition-case nil |
| 4880 | (prog1 (read (current-buffer)) | 4890 | (prog1 (read (current-buffer)) |
| 4881 | ;; Error handling. | 4891 | ;; Error handling. |
| @@ -5027,25 +5037,22 @@ Return ATTR." | |||
| 5027 | "/bin:/usr/bin") | 5037 | "/bin:/usr/bin") |
| 5028 | "/bin:/usr/bin")))) | 5038 | "/bin:/usr/bin")))) |
| 5029 | (own-remote-path | 5039 | (own-remote-path |
| 5030 | ;; We cannot apply `tramp-send-command-and-read' because | 5040 | ;; The login shell could return more than just the $PATH |
| 5031 | ;; the login shell could return more than just the $PATH | 5041 | ;; string. So we use `tramp-end-of-heredoc' as marker. |
| 5032 | ;; string. So we emulate that function. | ||
| 5033 | (when elt2 | 5042 | (when elt2 |
| 5034 | (tramp-send-command | 5043 | (tramp-send-command-and-read |
| 5035 | vec | 5044 | vec |
| 5036 | (format | 5045 | (format |
| 5037 | "%s -l %s 'echo \\\"$PATH\\\"'" | 5046 | "%s -l %s 'echo %s \\\"$PATH\\\"'" |
| 5038 | (tramp-get-method-parameter | 5047 | (tramp-get-method-parameter |
| 5039 | (tramp-file-name-method vec) 'tramp-remote-shell) | 5048 | (tramp-file-name-method vec) 'tramp-remote-shell) |
| 5040 | (mapconcat | 5049 | (mapconcat |
| 5041 | 'identity | 5050 | 'identity |
| 5042 | (tramp-get-method-parameter | 5051 | (tramp-get-method-parameter |
| 5043 | (tramp-file-name-method vec) 'tramp-remote-shell-args) | 5052 | (tramp-file-name-method vec) 'tramp-remote-shell-args) |
| 5044 | " "))) | 5053 | " ") |
| 5045 | (with-current-buffer (tramp-get-connection-buffer vec) | 5054 | (tramp-shell-quote-argument tramp-end-of-heredoc)) |
| 5046 | (goto-char (point-max)) | 5055 | nil (regexp-quote tramp-end-of-heredoc))))) |
| 5047 | (forward-line -1) | ||
| 5048 | (read (current-buffer)))))) | ||
| 5049 | 5056 | ||
| 5050 | ;; Replace place holder `tramp-default-remote-path'. | 5057 | ;; Replace place holder `tramp-default-remote-path'. |
| 5051 | (when elt1 | 5058 | (when elt1 |