From owner-freebsd-questions@freebsd.org Tue May 29 09:10:03 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4EFCFEFCA04 for ; Tue, 29 May 2018 09:10:03 +0000 (UTC) (envelope-from cuihao.leo@gmail.com) Received: from mail-ua0-x22b.google.com (mail-ua0-x22b.google.com [IPv6:2607:f8b0:400c:c08::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DEEB27EE1A for ; Tue, 29 May 2018 09:10:02 +0000 (UTC) (envelope-from cuihao.leo@gmail.com) Received: by mail-ua0-x22b.google.com with SMTP id d4-v6so9476542ual.10 for ; Tue, 29 May 2018 02:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=iEoMpdofL1q1S2p2upFS2AeDrCB9+LvuIlsynQ1at5M=; b=dRlh2UcwOY4URrcQMH1TkJaErJADralZtdCdpeJpwPaswyB3d/+I0QRqg3ha17zeOK KcU6jBGyopeoJLC4O9k9SymZ6J4uugHvs71XwuFb2gV+htG50jxUWwqiJTH4+KYNIGl8 TCDGewrPzDcGzOj+ITCnwK7AyqYfkl4ZJnTW2UPiFRqKRFz/GCH1u0ELBfYd7eN6enkS 2sMvmy5mzK2Tbihp2RIndr/+LcpnRYY6KJgs0pQURKa0CGXWBpkgMKUwaGvLjPkBH0Zn uU97+VS4bn3hNp3nYUuExMlHz2LuIP2hPP8P7t+kvxL71BMck/o1yIS+QtbHy3hnt4+3 kMdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=iEoMpdofL1q1S2p2upFS2AeDrCB9+LvuIlsynQ1at5M=; b=Cbpg64h/L443ki8Sdb3O18khfkAN0UcPW3KcXoAqSevZwMQOH6TQh2BHG63GpZK5cC vFW5muM5R6j47udVdExwocvq1vnUZ9+wX+MyHBmCxRzeHEWPeLu1xLfmW5HYWiifjyUb 6XDZtG4kAOHr1y5/3qs4OHhQiuZfp2Yt4+N4YjRQc9QKfxBDT6Q8h9QxhS92T10GJglk xZoUEnNCEU1wL3r4JhFKsXp+ryfJ9J7ngLivSODqSH3WFh66gEgK42pJLu5Mp89nLUNi AUNEualaiQ7e2YOF2itFcgmZrVxw64YjtpOVrASVwBZTrdvrB0aNVvR7BKsqvAEBlGNL djfQ== X-Gm-Message-State: ALKqPwc6evHQuEQbiIuF2/7YW04PWlKyxM+MmLbfAR0YYKOd2o9elRou 8HU93VveQEXR5Iqh4VAIdy9quxhuRoBIBphWwWmZug== X-Google-Smtp-Source: ADUXVKKE3oJicDzRc5PdNgHNdAAMmGX1Y1juoYk63GDvbr5YhucxMbkGvR7PKDgOfNP0u155E6wU434GL4RC9acVQZY= X-Received: by 2002:ab0:2508:: with SMTP id j8-v6mr10498484uan.83.1527585002182; Tue, 29 May 2018 02:10:02 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:490c:0:0:0:0:0 with HTTP; Tue, 29 May 2018 02:10:01 -0700 (PDT) From: =?UTF-8?B?5bSU54GPIChDVUkgSGFvKQ==?= Date: Tue, 29 May 2018 17:10:01 +0800 Message-ID: Subject: `reset` command makes backspace unusable To: freebsd-questions@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2018 09:10:03 -0000 Hi, new to FreeBSD. On Linux, I often use `reset` command to recover an broken terminal. On FreeBSD, `reset` seems to render backspace unusable in some CLI programs. Steps to reproduce the problem: 1. SSH login FreeBSD server from a Linux terminal emulator. TERM is set to `xterm-256color`. I tried Konsole / Termite. Both reproducible. But xterm/uxterm doesn't trigger the problem. 2. Executing `reset` on FreeBSD. 3. Then pressing backspace will yields `^?` instead of backward delete in most CLI programs including bash/vim/cat, but not tcsh and sh. Like this: wm@wmc:~$ reset Erase is backspace. wm@wmc:~$ ^?^?^?^? # typing backspace... I googled about the problem. `stty erase ^?` after `reset`, or `reset -e ^?` fix it. But I still wonder why `reset` doesn't work like on Linux. I do some investigation, here are some of my observations: 1. terminal line settings (`stty -a`) I checked the output of `stty -a`. On Linux terminal (Termite), I saw `erase =3D ^?`. For full output, see https://cfp.vim-cn.com/cbff6 After SSH login FreeBSD, `stty -a` shows `erase =3D ^?; erase2 =3D ^H`, which seem to be consistent with Linux. See https://cfp.vim-cn.com/cbff7 But after `reset`, the settings changed and becomes `erase =3D ^H; erase2 =3D ^H`. see https://cfp.vim-cn.com/cbff8 2. termcap It seems default terminal line settings are determined by termcap db. I checked `/etc/termcap` and found the entry of `xterm-256color`, which inherits settings of `xterm-basic` entry. `xterm-basic` sets `kb=3D^H`. On Linux, I get the termcap settings by `infocmp -Cr`. Terminal `xterm-256color` sets `kb=3D^H`, while `xterm-termite` sets `kb=3D\177`. I tried to override FreeBSD termcap settings in `~/.termcap`: xterm-256color|xterm alias 3:\ :Co#256:pa#32767:\ :kb=3D\177:\ :AB=3D\E[48;5;%dm:AF=3D\E[38;5;%dm:tc=3Dxterm-new Above settings indeed works and `reset` won't alter erase setting. However, Linux `xterm-256color` termcap does set `kb=3D^H` like FreeBSD, but it doesn't cause the problem on Linux. Although I have found several workaround to fix backspace problem, may anyone explain why terminal settings inconsistent on Linux and FreeBSD? Is this a bug or just some compatibility issues? Are there other compatibility issues with Linux terminal emulator? --=20 =E5=B4=94=E7=81=8F / CUI Hao Homepage: i-yu.me Twitter: @cuihaoleo