Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Jan 2020 16:57:58 +0000
From:      John F Carr <jfc@mit.edu>
To:        "freebsd-current@freebsd.org" <freebsd-current@freebsd.org>
Subject:   Emacs tramp mode doesn't work with CURRENT
Message-ID:  <B386FB6D-0771-4337-90C7-8A7E41C2D7F8@exchange.mit.edu>

next in thread | raw e-mail | index | archive | help
I use emacs tramp mode, which opens an ssh connection to a remote machine f=
or file access.  It works to Linux and FreeBSD 12.1, but not to CURRENT.  T=
here 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 she=
lls.  It could also be caused by a change to sshd or something I haven't th=
rough of.

Here is a longer explanation.

Emacs tramp mode opens an ssh connection to a remote machine.  It doesn't w=
ant 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 ch=
aracters.  "_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
#$=20

where again the middle ^H is a two character sequence and the others are ba=
ckspace 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
#$=20

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 eith=
er.  I put set +V and set +E in my .profile thinking that would turn off li=
ne editing but there was no change.  Probably the shell still takes raw inp=
ut.

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 sign=
ed.  Shouldn't matter, but I haven't tried 12.1 on ARM so I can't swear it =
works.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B386FB6D-0771-4337-90C7-8A7E41C2D7F8>