diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2009-12-07 06:38:06 +0000 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2009-12-07 06:38:06 +0000 |
commit | dab816a917fffcd49a26b422a7b5d435bc3e8b78 (patch) | |
tree | 49d71169cddafc9e5582639111d89316900c47d2 /lisp | |
parent | a91e1f6bf8c2c1a721d660dbb49bede3adde0a38 (diff) | |
download | emacs-dab816a917fffcd49a26b422a7b5d435bc3e8b78.tar.gz emacs-dab816a917fffcd49a26b422a7b5d435bc3e8b78.tar.bz2 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'.
Diffstat (limited to 'lisp')
-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 @@ +2009-12-07 Michael Albinus <michael.albinus@gmx.de> + + 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'. + 2009-12-07 Dan Nicolaescu <dann@ics.uci.edu> 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." (when (and p (processp p)) (delete-process p)) (setenv "TERM" tramp-terminal-type) - (setenv "PS1" "$ ") + (setenv "PS1" tramp-initial-end-of-output) (tramp-message vec 3 "Opening connection for %s@%s using %s..." 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." :group 'tramp :type 'string) +;; ksh on OpenBSD 4.5 requires, that PS1 contains a `#' character for +;; root users. It uses the `$' character for other users. In order +;; to guarantee a proper prompt, we use "#$" for the prompt. + +(defvar tramp-end-of-output + (format + "///%s#$" + (md5 (concat (prin1-to-string process-environment) (current-time-string)))) + "String used to recognize end of output. +The '$' character at the end is quoted; the string cannot be +detected as prompt when being sent on echoing hosts, therefore.") + +(defconst tramp-initial-end-of-output "#$ " + "Prompt when establishing a connection.") + (defvar tramp-methods `(("rcp" (tramp-login-program "rsh") (tramp-login-args (("%h") ("-l" "%u"))) @@ -585,8 +600,9 @@ files conditionalize this setup based on the TERM environment variable." ;; `tramp-compute-multi-hops'. (tramp-login-args (("-load") ("%h") ("-t") (,(format - "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=$ '" - tramp-terminal-type)) + "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'" + tramp-terminal-type + tramp-initial-end-of-output)) ("/bin/sh"))) (tramp-remote-sh "/bin/sh") (tramp-copy-program nil) @@ -1030,7 +1046,7 @@ Sometimes the prompt is reported to look like \"login as:\"." (defcustom tramp-shell-prompt-pattern ;; Allow a prompt to start right after a ^M since it indeed would be ;; displayed at the beginning of the line (and Zsh uses it). - "\\(?:^\\|\r\\)[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*" + "\\(?:^\\|\r\\)[^#$%>\n]*#?[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*" "Regexp to match prompts from remote shell. Normally, Tramp expects you to configure `shell-prompt-pattern' 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, Tramp recognizes things matched by `shell-prompt-pattern' as prompt, and also things matched by this variable. The default value of this variable is similar to the default value of `shell-prompt-pattern', -which should work well in many cases." +which should work well in many cases. + +This regexp must match both `tramp-initial-end-of-output' and +`tramp-end-of-output'." :group 'tramp :type 'regexp) @@ -1587,14 +1606,6 @@ means to use always cached values for the directory contents." ;;; Internal Variables: -(defvar tramp-end-of-output - (format - "///%s$" - (md5 (concat (prin1-to-string process-environment) (current-time-string)))) - "String used to recognize end of output. -The '$' character at the end is quoted; the string cannot be -detected as prompt when being sent on echoing hosts, therefore.") - (defvar tramp-current-method nil "Connection method for this *tramp* buffer.") @@ -6350,7 +6361,7 @@ file exists and nonzero exit status otherwise." (when extra-args (setq shell (concat shell " " extra-args)))) (tramp-message vec 5 "Starting remote shell `%s' for tilde expansion..." shell) - (let ((tramp-end-of-output "$ ")) + (let ((tramp-end-of-output tramp-initial-end-of-output)) (tramp-send-command vec (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." "Set up an interactive shell. 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 "$ ")) + (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 @@ -7147,7 +7158,7 @@ connection if a previous connection has died for some reason." (setenv "TERM" tramp-terminal-type) (setenv "LC_ALL" "C") (setenv "PROMPT_COMMAND") - (setenv "PS1" "$ ") + (setenv "PS1" tramp-initial-end-of-output) (let* ((target-alist (tramp-compute-multi-hops vec)) (process-connection-type tramp-process-connection-type) (process-adaptive-read-buffering nil) @@ -7271,9 +7282,9 @@ function waits for output unless NOOUTPUT is set." (defun tramp-wait-for-output (proc &optional timeout) "Wait for output from remote rsh command." (with-current-buffer (process-buffer proc) - (let* (;; Initially, `tramp-end-of-output' is "$ ". There might + (let* (;; Initially, `tramp-end-of-output' is "#$ ". There might ;; be leading escape sequences, which must be ignored. - (regexp (format "[^$\n]*%s\r?$" (regexp-quote tramp-end-of-output))) + (regexp (format "[^#$\n]*%s\r?$" (regexp-quote tramp-end-of-output))) ;; Sometimes, the commands do not return a newline but a ;; null byte before the shell prompt, for example "git ;; ls-files -c -z ...". |