Hi. Many thanks for your reply. I give the results of all the
diagnostics below.
Post by Stephane CHAZELASPost by kjPost by Stephane CHAZELAS[...]
Post by kjOur system just underwent a major overhaul, and now on some terminals,
and *only under zsh*, backspace no longer erases to the left, but
instead it erases under the cursor. Under bash, however, on every
terminal (including those with the bad backspace action under zsh)
backspace still erases to the left. Given this, it seems fair to
hypothesize that the root of the problem has to do with the
configuration of zsh in the new system.
What do you see when you press <Ctrl-V><Backspace> on your
terminal?
% ^[[3~
(where the leading " % " stands for my shell prompt.)
That sequence shouldn't be sent by the backspace key but by the
delete key.
But note that in the data shown below, there is one case in which
backspace sends ^? and yet it still fails to work.
Post by Stephane CHAZELASPost by kj"^D" delete-char-or-list
"^H" backward-delete-char
"^[[3~" delete-char
"^?" backward-delete-char
So zsh is fine, that's your terminal or possibly ssh/sshd,
telnet/telnetd, rlogin/rlogind, screen (depending on how you
connect to your remote hosts) that's doing some wrong
translations.
But if so, I don't understand why bash works. For example, if I
connect to this server from the local Mac's Terminal app via ssh (no
screen at all), my login shell is zsh, and my backspace key doesn't do
anything. If this problem were due to ssh, one would expect that
switching to bash on the same ssh session would make no difference,
but this is not so: if within that very same ssh/zsh session I execute
the command 'bash', now, in the resulting bash shell interaction, the
backspace key works fine. It was this piece of evidence that lead me
to suspect zsh in the first place.
Post by Stephane CHAZELASCould you please clarify what you're doing.
My normal sequence is to start the Terminal app in my iMac workstation
(machine A) and immediately to ssh to our main Linux server, which, as
of very recently, is a 64-bit machine running Ubuntu (machine B), but
used to be a 32-bit machine running SuSE (machine C). At any point I
can toggle the setting of the "Delete key sends backspace" option in
the Terminal app, which becomes effective immediately for the
currently active Terminal window. Also, I should note that the shell
for machines B and C is zsh, but for machine A the shell is bash.
Below I summarize the results of the diagnostics I ran, according to
your suggestions, plus a couple more of my own.
This summary is divided in two parallel sections which differ only in
the setting of the "Delete key sends backspace" option in the Terminal
app. The first of these two sections (in which this option is
unchecked) corresponds to the setting I used without any difficulties
until we started using machine B as our main linux host.
In each group of lines, the first line indicates the machine (A, B, or
C) under which the diagnostics were run.
The second line shows the two outputs I see when I hit
<Ctrl-V><Backspace>.
The third and fourth lines are the outputs of "echo $TERM" and
"infocmp -1 | grep -e dhc1 -e bs", respectively.
The fifth and sixth lines describe the behavior of the backspace key
on the command line and within a regular (i.e. non-shell) Emacs
buffer, respectively. On these lines, by "OK" I mean that hitting the
backspace key causes the cursor to move to the left and delete one
character; i.e. the desired behavior. In the case of Emacs, when the
this behavior is not "OK", I give the string that Emacs displays in
the "echo area" at the bottom of the screen. (Also, note the line
that I've marked with ***; under these conditions backspace fails, and
yet <Ctrl-V><Backspace> produces ^? .)
The seventh line indicates whether TERMCAP has been defined. (Usually
it isn't, but the value is the same whenever it is, and I give it at
the end of this post. BTW, I don't know for sure what sets this
variable, but I suppose it's GNU screen.)
The remaining lines (which are present only for machines B and C,
since bindkey is not available in bash) is the output of "bindkey |
grep delete".
=========================================================
"Delete key sends backspace" option in Terminal UNCHECKED
=========================================================
A
^?
xterm-color
kbs=^H,
backspace on CL: OK
backspace on Emacs: OK
TERMCAP?: NO
B
^?
xterm-color
kbs=^H,
backspace on CL: nothing happens ***
backspace on Emacs: OK
TERMCAP?: NO
"^D" delete-char-or-list
"^H" backward-delete-char
"^?" delete-char
B
^[[3~
screen
kbs=\177,
backspace on CL: nothing happens
backspace on Emacs: "End of buffer" (beep)
TERMCAP?: YES
"^D" delete-char-or-list
"^H" backward-delete-char
"^[[3~" delete-char
"^?" backward-delete-char
C
^?
xterm-color
kbs=^H,
backspace on CL: OK
backspace on Emacs: OK
TERMCAP?: NO
"^D" delete-char-or-list
"^H" backward-delete-char
"^[[3~" delete-char
"^?" backward-delete-char
C
^?
screen
kbs=\177,
backspace on CL: OK
backspace on Emacs: OK
TERMCAP?: NO
"^D" delete-char-or-list
"^H" backward-delete-char
"^[[3~" delete-char
"^?" backward-delete-char
=======================================================
"Delete key sends backspace" option in Terminal CHECKED
=======================================================
A
^H
xterm-color
kbs=^H,
backspace on CL: OK
backspace on Emacs: OK
B
^H
xterm-color
kbs=^H,
backspace on CL: OK
backspace on Emacs: "C-h (Type ? for further options)-"
TERMCAP?: NO
"^D" delete-char-or-list
"^H" backward-delete-char
"^?" delete-char
B
^H
screen
kbs=\177,
backspace on CL: OK
backspace on Emacs: "C-h (Type ? for further options)-"
TERMCAP?: YES
"^D" delete-char-or-list
"^H" backward-delete-char
"^[[3~" delete-char
"^?" backward-delete-char
C
^H
xterm-color
kbs=^H,
backspace on CL: OK
backspace on Emacs: "C-h (Type ? for further options)-"
TERMCAP?: NO
"^D" delete-char-or-list
"^H" backward-delete-char
"^[[3~" delete-char
"^?" backward-delete-char
C
^H
screen
kbs=\177,
backspace on CL: OK
backspace on Emacs: "C-h (Type ? for further options)-"
TERMCAP?: NO
"^D" delete-char-or-list
"^H" backward-delete-char
"^[[3~" delete-char
"^?" backward-delete-char
Also, in most cases $TERMCAP is not defined, but in those where it is, its value is:
SC|screen|VT 100/ANSI X3.64 virtual terminal:\
:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:\
:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\
:do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\
:le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\
:li#40:co#126:am:xn:xv:LP:sr=\EM:al=\E[L:AL=\E[%dL:\
:cs=\E[%i%d;%dr:dl=\E[M:DL=\E[%dM:dc=\E[P:DC=\E[%dP:\
:im=\E[4h:ei=\E[4l:mi:IC=\E[%d@:ks=\E[?1h\E=:\
:ke=\E[?1l\E>:vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l:\
:ti=\E[?1049h:te=\E[?1049l:us=\E[4m:ue=\E[24m:so=\E[3m:\
:se=\E[23m:md=\E[1m:mr=\E[7m:me=\E[m:ms:\
:Co#8:pa#64:AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:\
:as=\E(0:ae=\E(B:\
:ac=\140\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:\
:k0=\E[10~:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:k5=\E[15~:\
:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:k;=\E[21~:\
:F1=\E[23~:F2=\E[24~:F3=\E[25~:F4=\E[26~:F5=\E[28~:\
:F6=\E[29~:F7=\E[31~:F8=\E[32~:F9=\E[33~:FA=\E[34~:\
:kb=^H:kh=\E[1~:@1=\E[1~:kH=\E[4~:@7=\E[4~:kN=\E[6~:\
:kP=\E[5~:kI=\E[2~:kD=\E[3~:ku=\EOA:kd=\EOB:kr=\EOC:\
:kl=\EOD:km:
TIA,
kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.