From 8520c25ca4990ae297af49a44dc554d628130fe4 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Tue, 28 Apr 2026 15:47:30 +0200 Subject: [PATCH] Lock TERM to linux for LXC noVNC console Append a guarded snippet to /root/.bash_profile that forces TERM=linux on physical LXC consoles (e.g. noVNC) for login shells. This prevents readline (8.2+) from querying CPR (ESC[6n) which can produce stray R;80R garbage; the change runs only for non-SSH sessions and detects /dev/console or /dev/ttyN. The block is only added if a __cs_console_term marker is not already present. --- misc/install.func | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/misc/install.func b/misc/install.func index 02f35a50..ee7818db 100644 --- a/misc/install.func +++ b/misc/install.func @@ -1181,6 +1181,26 @@ fi EOF fi + # For LXC login shells (bash_profile runs before readline initialises): + # lock TERM=linux on the physical console so readline never queries CPR. + # This must run in bash_profile, not bashrc, because login shells source + # bash_profile first — readline reads TERM before any profile.d script runs. + if ! grep -q '__cs_console_term' /root/.bash_profile 2>/dev/null; then + cat >>/root/.bash_profile <<'EOF' + +# __cs_console_term: lock TERM=linux on LXC noVNC console to prevent R;80R garbage +# (readline 8.2+ sends ESC[6n if TERM supports CPR; linux terminfo has no CPR cap) +if [ -z "${SSH_CONNECTION:-}${SSH_TTY:-}" ]; then + _ct=$(tty 2>/dev/null) + case "$_ct" in + /dev/console|/dev/tty[0-9]*) + export TERM=linux ;; + esac + unset _ct +fi +EOF + fi + # Get OS information local os_name="$OS_TYPE" local os_version="$OS_VERSION"