Emacs tramp mode doesn't work with CURRENT

From: John F Carr <jfc_at_mit.edu>
Date: Tue, 28 Jan 2020 16:57:58 +0000
I use emacs tramp mode, which opens an ssh connection to a remote machine for file access.  It works to Linux and FreeBSD 12.1, but not to CURRENT.  There has been a change in the way characters are echoed by the shell, with 12.1 treating a consecutive run of backspace as an atomic unit and CURRENT processing them one at a time.  This is not necessarily a bug, but it is a nuisance and independently it is suboptimal.

I would like to blame libedit, which changed since 12.1.  I didn't see any changes in pty code and the problem happens with at least two different shells.  It could also be caused by a change to sshd or something I haven't through of.

Here is a longer explanation.

Emacs tramp mode opens an ssh connection to a remote machine.  It doesn't want to see input echoed back so it runs

stty -inlcr -onlcr -echo kill '^U' erase '^H'

This doesn't do anything useful if a shell is running in line editing mode (raw) instead of using the tty (cooked).  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 CURRENT 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.

I tried both /bin/sh and /bin/csh as shells and tramp didn't work with either.  I put set +V and set +E in my .profile thinking that would turn off line editing but there was no change.  Probably the shell still takes raw input.

A possible complicating factor is the CURRENT machines are both 64 bit ARM and the 12.1 machine is amd64.  One has unsigned characters, the other signed.  Shouldn't matter, but I haven't tried 12.1 on ARM so I can't swear it works.
Received on Tue Jan 28 2020 - 15:58:24 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:22 UTC