GNU bug report logs -
#39399
tramp depends on unstable details of shell command line processing
Previous Next
Reported by: John F Carr <jfc <at> mit.edu>
Date: Sun, 2 Feb 2020 21:30:02 UTC
Severity: normal
Tags: patch
Done: Michael Albinus <michael.albinus <at> gmx.de>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Thu, 06 Feb 2020 10:13:47 +0100
with message-id <87o8ucoz78.fsf <at> gmx.de>
and subject line Re: bug#39399: tramp depends on unstable details of shell command line processing
has caused the debbugs.gnu.org bug report #39399,
regarding tramp depends on unstable details of shell command line processing
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
39399: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=39399
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
I use emacs tramp mode for remote editing. It stopped working on my FreeBSD systems when I upgraded to a development version. The cause appears to be due to /bin/sh reprinting the entire line when a backspace is sent rather than sending only a backspace-space-backspace sequence. The failure follows a change in the line editing library (shared with NetBSD) rather than the shell itself.
Environment is emacs 24.5 or 26.3 running on Mac OS Catalina. The remote system is FreeBSD 13.0 development. Tramp works with Linux or FreeBSD 12.1 as the remote system.
Here's what happens.
I load tramp and open a file like /ssh:user <at> host:/. Emacs spawns ssh to connect. The first thing tramp does is send
stty -inlcr -onlcr -echo kill '^U' erase '^H'
But this doesn't do much because the tty is in raw mode rather than cooked due to the shell's line editor. So tramp falls back to a hack to detect echoed input. It sends "_echo" followed by a string of backspace characters. "_echo" is unlikely to appear in program output.
Here is the next command after the initial stty:
_echo^H^H^H^H^Hstty icanon erase ^H cols 32767_echo^H^H^H^H^H
The groups of 5 ^H represent 5 backspace characters and the lone ^H in the middle is a two character sequence for stty.
The terminal output from a 12.1 system is
_echo^H ^H^H ^H^H ^H^H ^H^H ^Hstty icanon erase ^H cols 32767_echo^H ^H^H ^H^H ^H^H ^H^H ^H
#$
where again the middle ^H is a two character sequence and the others are backspace characters. There is a carriage return between the two lines. "#$ " is the shell prompt set by tramp.
The terminal output from a FreeBSD 13.0 development branch system is
_echo
#$ _ech ^H
#$ _ec ^H
#$ _e ^H
#$ _ ^H
#$ ^Hstty icanon erase ^H cols 32767_echo
#$ stty icanon erase ^H cols 32767_ech ^H
#$ stty icanon erase ^H cols 32767_ec ^H
#$ stty icanon erase ^H cols 32767_e ^H
#$ stty icanon erase ^H cols 32767_ ^H
#$ stty icanon erase ^H cols 32767 ^H
#$
with carriage returns between lines. This does not make sense to emacs, which hangs waiting for something it recognizes. I can recover by hitting control-G which aborts the tramp connection.
This issue is also reported to FreeBSD at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=243807.
[Message part 3 (message/rfc822, inline)]
Version: 27.2
John F Carr <jfc <at> mit.edu> writes:
Hi John,
>> I've digged further. Likely, the problem can be avoided if we disable
>> command line editing of the shell. Tramp does it already if the remote
>> shell is zsh; I've added a similar parameter to the bash invocation. For
>> other shells, like ksh, I haven't found a simple parameter.
>>
>> For that class of shells, I've added code which installs a temporary
>> ~/.editrc file, containing the line 'edit off'.
>>
>> Could you please migrate to Tramp 2.4.3.1 from GNU ELPA? On top of this,
>> install the appended patch.
>>
>> And pls report, whether it works for you.
>
> Your change applied to tramp 2.4.3 from ELPA works.
Thanks for the feedback. Since I have no *BSD machine, I couldn't test
the patch; it was rather a shot into the dark.
I've pushed the patch, slightly modified, to the Emacs and Tramp
repositories. It won't appear with Emacs 27.1, because it is too late to
commit such serious changes so close to its release; but I will merge it
into the emacs-27 codebase after Emacs 27.1 has been released.
The next GNU ELPA Tramp release, 2.4.3.2, will carry this patch. It will
appear in a couple of weeks.
Best regards, Michael.
This bug report was last modified 4 years and 294 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.