diff options
| author | Michael Albinus | 2009-12-07 06:38:06 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-12-07 06:38:06 +0000 |
| commit | dab816a917fffcd49a26b422a7b5d435bc3e8b78 (patch) | |
| tree | 49d71169cddafc9e5582639111d89316900c47d2 | |
| parent | a91e1f6bf8c2c1a721d660dbb49bede3adde0a38 (diff) | |
| download | emacs-dab816a917fffcd49a26b422a7b5d435bc3e8b78.tar.gz emacs-dab816a917fffcd49a26b422a7b5d435bc3e8b78.zip | |
Handle prompt rules of ksh in OpenBSD 4.5. Reported by Raphaël
Berbain <raphael.berbain@gmail.com>.
* net/tramp.el (tramp-end-of-output): Move up. Use `#' and `$'
characters.
(tramp-initial-end-of-output): New defconst.
(tramp-methods, tramp-find-shell)
(tramp-open-connection-setup-interactive-shell)
(tramp-maybe-open-connection): Use it.
(tramp-shell-prompt-pattern, tramp-wait-for-output): Handle
existence of `#' and `$'.
* net/tramp-fish.el (tramp-fish-maybe-open-connection): Use
`tramp-initial-end-of-output'.
| -rw-r--r-- | lisp/ChangeLog | 17 | ||||
| -rw-r--r-- | lisp/net/tramp-fish.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 45 |
3 files changed, 46 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1630f37ba4d..b1472f76bfb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2009-12-07 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | Handle prompt rules of ksh in OpenBSD 4.5. Reported by Raphaël | ||
| 4 | Berbain <raphael.berbain@gmail.com>. | ||
| 5 | |||
| 6 | * net/tramp.el (tramp-end-of-output): Move up. Use `#' and `$' | ||
| 7 | characters. | ||
| 8 | (tramp-initial-end-of-output): New defconst. | ||
| 9 | (tramp-methods, tramp-find-shell) | ||
| 10 | (tramp-open-connection-setup-interactive-shell) | ||
| 11 | (tramp-maybe-open-connection): Use it. | ||
| 12 | (tramp-shell-prompt-pattern, tramp-wait-for-output): Handle | ||
| 13 | existence of `#' and `$'. | ||
| 14 | |||
| 15 | * net/tramp-fish.el (tramp-fish-maybe-open-connection): Use | ||
| 16 | `tramp-initial-end-of-output'. | ||
| 17 | |||
| 1 | 2009-12-07 Dan Nicolaescu <dann@ics.uci.edu> | 18 | 2009-12-07 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 19 | ||
| 3 | Get the background mode from the terminal for xterm, and set | 20 | Get the background mode from the terminal for xterm, and set |
diff --git a/lisp/net/tramp-fish.el b/lisp/net/tramp-fish.el index 8db5dc82fd9..618cd3fa1f7 100644 --- a/lisp/net/tramp-fish.el +++ b/lisp/net/tramp-fish.el | |||
| @@ -1111,7 +1111,7 @@ connection if a previous connection has died for some reason." | |||
| 1111 | (when (and p (processp p)) | 1111 | (when (and p (processp p)) |
| 1112 | (delete-process p)) | 1112 | (delete-process p)) |
| 1113 | (setenv "TERM" tramp-terminal-type) | 1113 | (setenv "TERM" tramp-terminal-type) |
| 1114 | (setenv "PS1" "$ ") | 1114 | (setenv "PS1" tramp-initial-end-of-output) |
| 1115 | (tramp-message | 1115 | (tramp-message |
| 1116 | vec 3 "Opening connection for %s@%s using %s..." | 1116 | vec 3 "Opening connection for %s@%s using %s..." |
| 1117 | tramp-current-user tramp-current-host tramp-current-method) | 1117 | tramp-current-user tramp-current-host tramp-current-method) |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index f3297ed13f5..d50b885955b 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -297,6 +297,21 @@ files conditionalize this setup based on the TERM environment variable." | |||
| 297 | :group 'tramp | 297 | :group 'tramp |
| 298 | :type 'string) | 298 | :type 'string) |
| 299 | 299 | ||
| 300 | ;; ksh on OpenBSD 4.5 requires, that PS1 contains a `#' character for | ||
| 301 | ;; root users. It uses the `$' character for other users. In order | ||
| 302 | ;; to guarantee a proper prompt, we use "#$" for the prompt. | ||
| 303 | |||
| 304 | (defvar tramp-end-of-output | ||
| 305 | (format | ||
| 306 | "///%s#$" | ||
| 307 | (md5 (concat (prin1-to-string process-environment) (current-time-string)))) | ||
| 308 | "String used to recognize end of output. | ||
| 309 | The '$' character at the end is quoted; the string cannot be | ||
| 310 | detected as prompt when being sent on echoing hosts, therefore.") | ||
| 311 | |||
| 312 | (defconst tramp-initial-end-of-output "#$ " | ||
| 313 | "Prompt when establishing a connection.") | ||
| 314 | |||
| 300 | (defvar tramp-methods | 315 | (defvar tramp-methods |
| 301 | `(("rcp" (tramp-login-program "rsh") | 316 | `(("rcp" (tramp-login-program "rsh") |
| 302 | (tramp-login-args (("%h") ("-l" "%u"))) | 317 | (tramp-login-args (("%h") ("-l" "%u"))) |
| @@ -585,8 +600,9 @@ files conditionalize this setup based on the TERM environment variable." | |||
| 585 | ;; `tramp-compute-multi-hops'. | 600 | ;; `tramp-compute-multi-hops'. |
| 586 | (tramp-login-args (("-load") ("%h") ("-t") | 601 | (tramp-login-args (("-load") ("%h") ("-t") |
| 587 | (,(format | 602 | (,(format |
| 588 | "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=$ '" | 603 | "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'" |
| 589 | tramp-terminal-type)) | 604 | tramp-terminal-type |
| 605 | tramp-initial-end-of-output)) | ||
| 590 | ("/bin/sh"))) | 606 | ("/bin/sh"))) |
| 591 | (tramp-remote-sh "/bin/sh") | 607 | (tramp-remote-sh "/bin/sh") |
| 592 | (tramp-copy-program nil) | 608 | (tramp-copy-program nil) |
| @@ -1030,7 +1046,7 @@ Sometimes the prompt is reported to look like \"login as:\"." | |||
| 1030 | (defcustom tramp-shell-prompt-pattern | 1046 | (defcustom tramp-shell-prompt-pattern |
| 1031 | ;; Allow a prompt to start right after a ^M since it indeed would be | 1047 | ;; Allow a prompt to start right after a ^M since it indeed would be |
| 1032 | ;; displayed at the beginning of the line (and Zsh uses it). | 1048 | ;; displayed at the beginning of the line (and Zsh uses it). |
| 1033 | "\\(?:^\\|\r\\)[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*" | 1049 | "\\(?:^\\|\r\\)[^#$%>\n]*#?[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*" |
| 1034 | "Regexp to match prompts from remote shell. | 1050 | "Regexp to match prompts from remote shell. |
| 1035 | Normally, Tramp expects you to configure `shell-prompt-pattern' | 1051 | Normally, Tramp expects you to configure `shell-prompt-pattern' |
| 1036 | correctly, but sometimes it happens that you are connecting to a | 1052 | correctly, but sometimes it happens that you are connecting to a |
| @@ -1038,7 +1054,10 @@ remote host which sends a different kind of shell prompt. Therefore, | |||
| 1038 | Tramp recognizes things matched by `shell-prompt-pattern' as prompt, | 1054 | Tramp recognizes things matched by `shell-prompt-pattern' as prompt, |
| 1039 | and also things matched by this variable. The default value of this | 1055 | and also things matched by this variable. The default value of this |
| 1040 | variable is similar to the default value of `shell-prompt-pattern', | 1056 | variable is similar to the default value of `shell-prompt-pattern', |
| 1041 | which should work well in many cases." | 1057 | which should work well in many cases. |
| 1058 | |||
| 1059 | This regexp must match both `tramp-initial-end-of-output' and | ||
| 1060 | `tramp-end-of-output'." | ||
| 1042 | :group 'tramp | 1061 | :group 'tramp |
| 1043 | :type 'regexp) | 1062 | :type 'regexp) |
| 1044 | 1063 | ||
| @@ -1587,14 +1606,6 @@ means to use always cached values for the directory contents." | |||
| 1587 | 1606 | ||
| 1588 | ;;; Internal Variables: | 1607 | ;;; Internal Variables: |
| 1589 | 1608 | ||
| 1590 | (defvar tramp-end-of-output | ||
| 1591 | (format | ||
| 1592 | "///%s$" | ||
| 1593 | (md5 (concat (prin1-to-string process-environment) (current-time-string)))) | ||
| 1594 | "String used to recognize end of output. | ||
| 1595 | The '$' character at the end is quoted; the string cannot be | ||
| 1596 | detected as prompt when being sent on echoing hosts, therefore.") | ||
| 1597 | |||
| 1598 | (defvar tramp-current-method nil | 1609 | (defvar tramp-current-method nil |
| 1599 | "Connection method for this *tramp* buffer.") | 1610 | "Connection method for this *tramp* buffer.") |
| 1600 | 1611 | ||
| @@ -6350,7 +6361,7 @@ file exists and nonzero exit status otherwise." | |||
| 6350 | (when extra-args (setq shell (concat shell " " extra-args)))) | 6361 | (when extra-args (setq shell (concat shell " " extra-args)))) |
| 6351 | (tramp-message | 6362 | (tramp-message |
| 6352 | vec 5 "Starting remote shell `%s' for tilde expansion..." shell) | 6363 | vec 5 "Starting remote shell `%s' for tilde expansion..." shell) |
| 6353 | (let ((tramp-end-of-output "$ ")) | 6364 | (let ((tramp-end-of-output tramp-initial-end-of-output)) |
| 6354 | (tramp-send-command | 6365 | (tramp-send-command |
| 6355 | vec | 6366 | vec |
| 6356 | (format "PROMPT_COMMAND='' PS1=%s PS2='' PS3='' exec %s" | 6367 | (format "PROMPT_COMMAND='' PS1=%s PS2='' PS3='' exec %s" |
| @@ -6621,7 +6632,7 @@ seconds. If not, it produces an error message with the given ERROR-ARGS." | |||
| 6621 | "Set up an interactive shell. | 6632 | "Set up an interactive shell. |
| 6622 | Mainly sets the prompt and the echo correctly. PROC is the shell | 6633 | Mainly sets the prompt and the echo correctly. PROC is the shell |
| 6623 | process to set up. VEC specifies the connection." | 6634 | process to set up. VEC specifies the connection." |
| 6624 | (let ((tramp-end-of-output "$ ")) | 6635 | (let ((tramp-end-of-output tramp-initial-end-of-output)) |
| 6625 | ;; It is useful to set the prompt in the following command because | 6636 | ;; It is useful to set the prompt in the following command because |
| 6626 | ;; some people have a setting for $PS1 which /bin/sh doesn't know | 6637 | ;; some people have a setting for $PS1 which /bin/sh doesn't know |
| 6627 | ;; about and thus /bin/sh will display a strange prompt. For | 6638 | ;; about and thus /bin/sh will display a strange prompt. For |
| @@ -7147,7 +7158,7 @@ connection if a previous connection has died for some reason." | |||
| 7147 | (setenv "TERM" tramp-terminal-type) | 7158 | (setenv "TERM" tramp-terminal-type) |
| 7148 | (setenv "LC_ALL" "C") | 7159 | (setenv "LC_ALL" "C") |
| 7149 | (setenv "PROMPT_COMMAND") | 7160 | (setenv "PROMPT_COMMAND") |
| 7150 | (setenv "PS1" "$ ") | 7161 | (setenv "PS1" tramp-initial-end-of-output) |
| 7151 | (let* ((target-alist (tramp-compute-multi-hops vec)) | 7162 | (let* ((target-alist (tramp-compute-multi-hops vec)) |
| 7152 | (process-connection-type tramp-process-connection-type) | 7163 | (process-connection-type tramp-process-connection-type) |
| 7153 | (process-adaptive-read-buffering nil) | 7164 | (process-adaptive-read-buffering nil) |
| @@ -7271,9 +7282,9 @@ function waits for output unless NOOUTPUT is set." | |||
| 7271 | (defun tramp-wait-for-output (proc &optional timeout) | 7282 | (defun tramp-wait-for-output (proc &optional timeout) |
| 7272 | "Wait for output from remote rsh command." | 7283 | "Wait for output from remote rsh command." |
| 7273 | (with-current-buffer (process-buffer proc) | 7284 | (with-current-buffer (process-buffer proc) |
| 7274 | (let* (;; Initially, `tramp-end-of-output' is "$ ". There might | 7285 | (let* (;; Initially, `tramp-end-of-output' is "#$ ". There might |
| 7275 | ;; be leading escape sequences, which must be ignored. | 7286 | ;; be leading escape sequences, which must be ignored. |
| 7276 | (regexp (format "[^$\n]*%s\r?$" (regexp-quote tramp-end-of-output))) | 7287 | (regexp (format "[^#$\n]*%s\r?$" (regexp-quote tramp-end-of-output))) |
| 7277 | ;; Sometimes, the commands do not return a newline but a | 7288 | ;; Sometimes, the commands do not return a newline but a |
| 7278 | ;; null byte before the shell prompt, for example "git | 7289 | ;; null byte before the shell prompt, for example "git |
| 7279 | ;; ls-files -c -z ...". | 7290 | ;; ls-files -c -z ...". |