From e3776734897f34385dc7a42b7f1542a9a6063039 Mon Sep 17 00:00:00 2001 From: millert Date: Fri, 8 Jul 2016 15:23:44 +0000 Subject: [PATCH] Pass errret pointer to setupterm() to prevent setupterm() from calling exit() when given an unknown terminal type. From Anton Lindqvist, who also upstreamed the fix. --- usr.bin/less/screen.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/usr.bin/less/screen.c b/usr.bin/less/screen.c index 5063250badd..a794afc680b 100644 --- a/usr.bin/less/screen.c +++ b/usr.bin/less/screen.c @@ -16,6 +16,7 @@ #include +#include #include #include @@ -266,6 +267,7 @@ get_term(void) { char *t1, *t2; char *term; + int err; /* * Find out what kind of terminal this is. @@ -274,8 +276,11 @@ get_term(void) term = DEFAULT_TERM; hardcopy = 0; - if (setupterm(term, 1, NULL) < 0) { - hardcopy = 1; + if (setupterm(term, 1, &err) < 0) { + if (err == 1) + hardcopy = 1; + else + errx(1, "%s: unknown terminal type", term); } if (hard_copy == 1) hardcopy = 1; -- 2.20.1