* Recent changes on tramp introduce a bug
@ 2008-01-22 5:57 Herbert Euler
2008-01-22 14:22 ` Michael Albinus
0 siblings, 1 reply; 4+ messages in thread
From: Herbert Euler @ 2008-01-22 5:57 UTC (permalink / raw)
To: michael.albinus; +Cc: emacs-devel
Hello,
The following changes to `tramp-wait-for-output' on net/tramp.el
introduce a bug:
cvs diff: I know nothing about 1.166
Index: net/tramp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/tramp.el,v
retrieving revision 1.165
retrieving revision 1.39.2.52
diff -F '^(defun [_a-zA-Z0-9$-]+ *(' -c -r1.165 -r1.39.2.52
*** net/tramp.el 23 Dec 2007 13:25:26 -0000 1.165
--- net/tramp.el 18 Mar 2007 14:11:07 -0000 1.39.2.52
*************** (defun tramp-send-command (vec command &
*** 6245,6260 ****
(defun tramp-wait-for-output (proc &optional timeout)
"Wait for output from remote rsh command."
(with-current-buffer (process-buffer proc)
! (let ((found
! (tramp-wait-for-regexp
! proc timeout
! ;; Initially, `tramp-end-of-output' is "$ ". There might
! ;; be leading escape sequences, which must be ignored.
! (format "^[^$\n]*%s\r?$" (regexp-quote tramp-end-of-output)))))
(if found
(let (buffer-read-only)
(goto-char (point-max))
! (forward-line -2)
(delete-region (point) (point-max)))
(if timeout
(tramp-error
--- 6247,6260 ----
(defun tramp-wait-for-output (proc &optional timeout)
"Wait for output from remote rsh command."
(with-current-buffer (process-buffer proc)
! ;; Initially, `tramp-end-of-output' is "$ ". There might be
! ;; leading escape sequences, which must be ignored.
! (let* ((regexp (format "^[^$\n]*%s\r?$" (regexp-quote tramp-end-of-output)))
! (found (tramp-wait-for-regexp proc timeout regexp)))
(if found
(let (buffer-read-only)
(goto-char (point-max))
! (re-search-backward regexp nil t)
(delete-region (point) (point-max)))
(if timeout
(tramp-error
I found this bug when I tried to open a remote file with tramp, while
ido-mode is turned on.
The old code uses (forward-line -2), the new code uses
(re-search-backward regexp nil t). When listing remote file names,
the different movements cause different result. Here is what such a
listing would look like before the two different pieces of code are
evaluated:
tmp/
tpop/
ypa/
///c8f0a82e28ac811d30acfc16c3610166
-!-
Where the symbol "-!-" indicates the point position. In the case of
the old code, point will be moved to just after "ypa/":
tmp/
tpop/
ypa/
-!-
///c8f0a82e28ac811d30acfc16c3610166
So the entire content after the newline character will be deleted.
However, in the case of the new code, point will be moved to the
beginning of the signature line:
tmp/
tpop/
ypa/
-!-///c8f0a82e28ac811d30acfc16c3610166
So there will be one more newline character after (delete-region
(point) (point-max)) is evaluated, compared to the old case. This one
more newline character will add an empty string "" to the completions
of file names, which will cause an error in ido-mode.
Regards,
Guanpeng Xu
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Recent changes on tramp introduce a bug
2008-01-22 5:57 Recent changes on tramp introduce a bug Herbert Euler
@ 2008-01-22 14:22 ` Michael Albinus
2008-01-23 3:07 ` Herbert Euler
0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2008-01-22 14:22 UTC (permalink / raw)
To: Herbert Euler; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 572 bytes --]
Herbert Euler <herberteuler@hotmail.com> writes:
> Hello,
Hi,
> The following changes to `tramp-wait-for-output' on net/tramp.el
> introduce a bug:
>
> The old code uses (forward-line -2), the new code uses
> (re-search-backward regexp nil t).
IIRC, (forward-line -2) results in an error if a command on the remote
host returns a result without a trailing newline. That's why Tramp
tries to remove now exactly the trailing prompt, and nothing else.
Could you, please, check whether the appended patch works for you?
> Regards,
> Guanpeng Xu
Best regards, Michael.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 4611 bytes --]
***************
*** 1433,1441 ****
;;; Internal Variables:
(defvar tramp-end-of-output
! (concat
! "///" (md5 (concat
! (prin1-to-string process-environment) (current-time-string))))
"String used to recognize end of output.")
(defvar tramp-current-method nil
--- 1433,1443 ----
;;; Internal Variables:
(defvar tramp-end-of-output
! (format
! "%s///%s%s"
! tramp-rsh-end-of-line
! (md5 (concat (prin1-to-string process-environment) (current-time-string)))
! tramp-rsh-end-of-line)
"String used to recognize end of output.")
(defvar tramp-current-method nil
***************
*** 5360,5381 ****
vec
(format "PROMPT_COMMAND='' PS1='$ ' PS2='' PS3='' exec %s" shell)
t))
(tramp-message vec 5 "Setting remote shell prompt...")
! ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we
! ;; must use "\n" here, not tramp-rsh-end-of-line. Kai left the
! ;; last tramp-rsh-end-of-line, Douglas wanted to replace that,
! ;; as well.
! (tramp-send-command
! vec
! (format "PS1='%s%s%s'"
! tramp-rsh-end-of-line
! tramp-end-of-output
! tramp-rsh-end-of-line)
! t)
(tramp-send-command vec "PS2=''" t)
(tramp-send-command vec "PS3=''" t)
(tramp-send-command vec "PROMPT_COMMAND=''" t)
(tramp-message vec 5 "Setting remote shell prompt...done"))
(t (tramp-message
vec 5 "Remote `%s' groks tilde expansion, good"
(tramp-get-method-parameter
--- 5362,5375 ----
vec
(format "PROMPT_COMMAND='' PS1='$ ' PS2='' PS3='' exec %s" shell)
t))
+ ;; Setting prompts.
(tramp-message vec 5 "Setting remote shell prompt...")
! (tramp-send-command vec (format "PS1='%s'" tramp-end-of-output) t)
(tramp-send-command vec "PS2=''" t)
(tramp-send-command vec "PS3=''" t)
(tramp-send-command vec "PROMPT_COMMAND=''" t)
(tramp-message vec 5 "Setting remote shell prompt...done"))
+
(t (tramp-message
vec 5 "Remote `%s' groks tilde expansion, good"
(tramp-get-method-parameter
***************
*** 5668,5680 ****
;; We can set $PS1 to `tramp-end-of-output' only when the echo has
;; been disabled. Otherwise, the echo of the command would be
;; regarded as prompt already.
! (tramp-send-command
! vec
! (format "PS1='%s%s%s'"
! tramp-rsh-end-of-line
! tramp-end-of-output
! tramp-rsh-end-of-line)
! t)
(tramp-send-command vec "PS2=''" t)
(tramp-send-command vec "PS3=''" t)
(tramp-send-command vec "PROMPT_COMMAND=''" t)
--- 5662,5668 ----
;; We can set $PS1 to `tramp-end-of-output' only when the echo has
;; been disabled. Otherwise, the echo of the command would be
;; regarded as prompt already.
! (tramp-send-command vec (format "PS1='%s'" tramp-end-of-output) t)
(tramp-send-command vec "PS2=''" t)
(tramp-send-command vec "PS3=''" t)
(tramp-send-command vec "PROMPT_COMMAND=''" t)
***************
*** 6249,6255 ****
(with-current-buffer (process-buffer proc)
;; Initially, `tramp-end-of-output' is "$ ". There might be
;; leading escape sequences, which must be ignored.
! (let* ((regexp (format "^[^$\n]*%s\r?$" (regexp-quote tramp-end-of-output)))
(found (tramp-wait-for-regexp proc timeout regexp)))
(if found
(let (buffer-read-only)
--- 6237,6247 ----
(with-current-buffer (process-buffer proc)
;; Initially, `tramp-end-of-output' is "$ ". There might be
;; leading escape sequences, which must be ignored.
! (let* ((regexp
! (if (string-match (regexp-quote "\n") tramp-end-of-output)
! (mapconcat
! 'identity (split-string tramp-end-of-output "\n") "\r?\n")
! (format "^[^$\n]*%s\r?$" (regexp-quote tramp-end-of-output))))
(found (tramp-wait-for-regexp proc timeout regexp)))
(if found
(let (buffer-read-only)
***************
*** 6833,6840 ****
vec (format "( %s / -nt / )" (tramp-get-test-command vec)))
(with-current-buffer (tramp-get-buffer vec)
(goto-char (point-min))
! (when (looking-at
! (format "\n%s\r?\n" (regexp-quote tramp-end-of-output)))
(format "%s %%s -nt %%s" (tramp-get-test-command vec)))))
(progn
(tramp-send-command
--- 6825,6831 ----
vec (format "( %s / -nt / )" (tramp-get-test-command vec)))
(with-current-buffer (tramp-get-buffer vec)
(goto-char (point-min))
! (when (looking-at (regexp-quote tramp-end-of-output))
(format "%s %%s -nt %%s" (tramp-get-test-command vec)))))
(progn
(tramp-send-command
[-- Attachment #3: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: Recent changes on tramp introduce a bug
2008-01-22 14:22 ` Michael Albinus
@ 2008-01-23 3:07 ` Herbert Euler
2008-01-23 20:56 ` Michael Albinus
0 siblings, 1 reply; 4+ messages in thread
From: Herbert Euler @ 2008-01-23 3:07 UTC (permalink / raw)
To: Michael Albinus; +Cc: emacs-devel
> Hi,
>
>> The following changes to `tramp-wait-for-output' on net/tramp.el
>> introduce a bug:
>>
>> The old code uses (forward-line -2), the new code uses
>> (re-search-backward regexp nil t).
>
> IIRC, (forward-line -2) results in an error if a command on the remote
> host returns a result without a trailing newline. That's why Tramp
> tries to remove now exactly the trailing prompt, and nothing else.
I see. That is a real bad feature among different implementations. :(
> Could you, please, check whether the appended patch works for you?
It works. Thank you very much! :D
Regards,
Guanpeng Xu
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Recent changes on tramp introduce a bug
2008-01-23 3:07 ` Herbert Euler
@ 2008-01-23 20:56 ` Michael Albinus
0 siblings, 0 replies; 4+ messages in thread
From: Michael Albinus @ 2008-01-23 20:56 UTC (permalink / raw)
To: Herbert Euler; +Cc: emacs-devel
Herbert Euler <herberteuler@hotmail.com> writes:
>> Could you, please, check whether the appended patch works for you?
>
> It works. Thank you very much! :D
I've committed it to CVS.
> Regards,
> Guanpeng Xu
Thanks for the report, and best regatds, Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-01-23 20:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-22 5:57 Recent changes on tramp introduce a bug Herbert Euler
2008-01-22 14:22 ` Michael Albinus
2008-01-23 3:07 ` Herbert Euler
2008-01-23 20:56 ` Michael Albinus
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.