From 46cdf8b7453e4322b815484654aefea9d8598531 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 9 Sep 2021 16:17:04 +0200 Subject: [PATCH] startup: if TERM is unset, try falling back to VT220 instead of failing Curses cannot function if not informed via TERM which type of terminal is being used. As many terminals are mostly compatible with a VT220, falling back to "vt220" when TERM is unset has a good chance of giving the user a usable nano, instead of simply failing. (Falling back to "vt100" is not good as it contains padding delays.) This partially addresses https://bugs.debian.org/991982. --- src/nano.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nano.c b/src/nano.c index 40409784..4e24b753 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2055,6 +2055,10 @@ int main(int argc, char **argv) } } + /* Curses needs TERM; if it is unset, try falling back to a VT220. */ + if (getenv("TERM") == NULL) + setenv("TERM", "vt220", 0); + /* Enter into curses mode. Abort if this fails. */ if (initscr() == NULL) exit(1);