# HG changeset patch # User Michael Albinus # Date 1260167886 0 # Node ID 9e96dbbd314ed8bf3d017a247c14a651990aa4d7 # Parent ad4147368f525ab9c4af9fdbf41deb07a2bf3c92 Handle prompt rules of ksh in OpenBSD 4.5. Reported by Rapha«³l Berbain . * 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'. diff -r ad4147368f52 -r 9e96dbbd314e lisp/ChangeLog --- a/lisp/ChangeLog Mon Dec 07 06:30:30 2009 +0000 +++ b/lisp/ChangeLog Mon Dec 07 06:38:06 2009 +0000 @@ -1,3 +1,20 @@ +2009-12-07 Michael Albinus + + Handle prompt rules of ksh in OpenBSD 4.5. Reported by RaphaĆ«l + Berbain . + + * 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 Get the background mode from the terminal for xterm, and set diff -r ad4147368f52 -r 9e96dbbd314e lisp/net/tramp-fish.el --- a/lisp/net/tramp-fish.el Mon Dec 07 06:30:30 2009 +0000 +++ b/lisp/net/tramp-fish.el Mon Dec 07 06:38:06 2009 +0000 @@ -1111,7 +1111,7 @@ (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 -r ad4147368f52 -r 9e96dbbd314e lisp/net/tramp.el --- a/lisp/net/tramp.el Mon Dec 07 06:30:30 2009 +0000 +++ b/lisp/net/tramp.el Mon Dec 07 06:38:06 2009 +0000 @@ -297,6 +297,21 @@ :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 @@ ;; `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 @@ (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 @@ 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 @@ ;;; 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 @@ (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 @@ "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 @@ (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 @@ (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 ...".